#! /bin/bash
. /usr/lib/network/network

vlan_up() {
    local vlan_interface
    load_profile "$1"

    if ifconfig $INTERFACE >/dev/null 2>&1; then
        report_fail "Interface $INTERFACE already exists and is not a bridge."
        exit 1
    else
        # I know, the ifconfig is sloppy, if you don't like it fix it!
        ifconfig $VLAN_RAW_DEV up
        ip link add link $VLAN_RAW_DEV name $INTERFACE type vlan id $VLAN_ID >/dev/null 2>&1
    fi
    bring_interface up "$INTERFACE"
    "$CONN_DIR/ethernet" up "$1"
    return 0
}

vlan_down() {
    local vlan_interface
    load_profile "$1"

    "$CONN_DIR/ethernet" down "$1"
    bring_interface down "$INTERFACE"
    ip link delete link $INTERFACE >/dev/null 2>&1
    return 0
}

# Returns status of profile - is it still functional?
vlan_status() {
    true
}

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