summaryrefslogtreecommitdiffstats
path: root/src/connections/ppp
blob: ce3c8ab27e0f1f1552363b22b21c5cddc4690a54 (plain)
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
#! /bin/bash
##################################
##
#  /usr/lib/network/connections/ppp
##
##################################

. /etc/rc.conf
. /etc/rc.d/functions
. /usr/lib/network/network


ppp_up() {
    load_profile "$1"
    [[ -z "$PEER" ]] && PEER=provider
    [[ -z "$PPP_TIMEOUT" ]] && PPP_TIMEOUT=30

    if ! /usr/sbin/pppd call "$PEER" updetach child-timeout "$PPP_TIMEOUT" linkname "$PEER"; then
       report_fail "Couldn't make pppd connection."
       return 1
    fi

    # wireless and wireless-dbus connections run this block when they call "ethernet up"; but ppp needs to do it itself
    # successfully running a new profile; erase any suspended profiles on this interface
    local interface="$INTERFACE"
    find "$STATE_DIR/suspend/" -maxdepth 1 -type f -printf '%f\n' \
	| while read prof; do
        # the pipe to "while read" will create a subshell, so sourced variables will already be in a sandbox
        # we just need to clear INTERFACE which is all we care about
        unset INTERFACE
        . "$STATE_DIR/suspend/$prof"
        if [[ "$interface" == "$INTERFACE" ]]; then
            rm "$STATE_DIR/suspend/$prof"
        fi
    done
}

ppp_down() {
    load_profile "$1"
    kill $(head -1 "/var/run/ppp-$(basename "$PEER").pid")
}

ppp_query() {
    "$CONN_DIR/ethernet" query "$@"
}

ppp_control() {
    "$CONN_DIR/wireless" control "$@"
}

ppp_verify() {
    local INTERFACE="$1"
    # do nothing
}

ppp_$1 "$2"
exit $?
# vim: set ts=4 et sw=4: