mac80211: fill some important capabilities into ht_capab in the hostapd config
[openwrt.git] / package / ppp / files / ppp.sh
1 scan_ppp() {
2 config_get ifname "$1" ifname
3 pppdev="${pppdev:-0}"
4 config_get unit "$1" unit
5 [ -z "$unit" ] && {
6 unit="$pppdev"
7 if [ "${ifname%%[0-9]*}" = ppp ]; then
8 unit="${ifname##ppp}"
9 [ "$pppdev" -le "$unit" ] && pppdev="$(($unit + 1))"
10 else
11 pppdev="$(($pppdev + 1))"
12 fi
13 config_set "$1" ifname "ppp$unit"
14 config_set "$1" unit "$unit"
15 }
16 }
17
18 start_pppd() {
19 local cfg="$1"; shift
20 local ifname
21
22 # make sure the network state references the correct ifname
23 scan_ppp "$cfg"
24 config_get ifname "$cfg" ifname
25 set_interface_ifname "$cfg" "$ifname"
26
27 # make sure only one pppd process is started
28 lock "/var/lock/ppp-${cfg}"
29 local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
30 [ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
31 lock -u "/var/lock/ppp-${cfg}"
32 return 0
33 }
34
35 # Workaround: sometimes hotplug2 doesn't deliver the hotplug event for creating
36 # /dev/ppp fast enough to be used here
37 [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
38
39 config_get device "$cfg" device
40 config_get unit "$cfg" unit
41 config_get username "$cfg" username
42 config_get password "$cfg" password
43 config_get keepalive "$cfg" keepalive
44
45 config_get connect "$cfg" connect
46 config_get disconnect "$cfg" disconnect
47 config_get pppd_options "$cfg" pppd_options
48 config_get_bool defaultroute "$cfg" defaultroute 1
49 [ "$defaultroute" -eq 1 ] && defaultroute="defaultroute replacedefaultroute" || defaultroute=""
50
51 interval="${keepalive##*[, ]}"
52 [ "$interval" != "$keepalive" ] || interval=5
53
54 config_get_bool peerdns "$cfg" peerdns 1
55 [ "$peerdns" -eq 1 ] && peerdns="usepeerdns" || peerdns=""
56
57 config_get demand "$cfg" demand
58 [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
59
60 config_get_bool ipv6 "$cfg" ipv6 0
61 [ "$ipv6" -eq 1 ] && ipv6="+ipv6" || ipv6=""
62
63 /usr/sbin/pppd "$@" \
64 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
65 ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
66 $peerdns \
67 $defaultroute \
68 ${username:+user "$username" password "$password"} \
69 unit "$unit" \
70 linkname "$cfg" \
71 ipparam "$cfg" \
72 ${connect:+connect "$connect"} \
73 ${disconnect:+disconnect "$disconnect"} \
74 ${ipv6} \
75 ${pppd_options}
76
77 lock -u "/var/lock/ppp-${cfg}"
78 }
79
80 setup_interface_ppp() {
81 local iface="$1"
82 local config="$2"
83
84 config_get device "$config" device
85
86 config_get mtu "$config" mtu
87 mtu=${mtu:-1492}
88 start_pppd "$config" \
89 mtu $mtu mru $mtu \
90 "$device"
91 }
92
This page took 0.054587 seconds and 5 git commands to generate.