blob: 1c038626af2b25a0288b4260cabd162c1c8d9d85 [file] [log] [blame]
#!/bin/sh
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Set the ARP gateway.
FLAGS_HELP="Usage:
$(basename $0)
$(basename $0) [true | false]
Turn on extra network state checking to make sure the default gateway
is reachable.
"
. /usr/share/misc/shflags
FLIMFLAM=org.chromium.flimflam
IMANAGER=$FLIMFLAM.Manager
usage() {
echo "$*"
echo
flags_help
exit 1
}
dbus () {
local obj=$1
local meth=$2
shift 2
dbus-send --system --print-reply --fixed --dest=$FLIMFLAM "$obj" "$meth" "$@"
}
get_manager () {
dbus / $IMANAGER.GetProperties | sed -n "/$1/s/.* //p"
}
display_arpgw () {
local arpgw=$(get_manager ArpGateway)
if [ -n "$arpgw" ] ; then
echo "Current Gateway ARP setting: " $arpgw
exit 0
fi
echo "This Flimflam instance does not support ArpGateway"
exit 0
}
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
if [ $# -lt 1 ]; then
display_arpgw
fi
set_arpgw=$1
if [ $set_arpgw != false -a $set_arpgw != true ] ; then
usage "Argument must be 'true' or 'false'"
fi
dbus / $IMANAGER.SetProperty string:"ArpGateway" variant:boolean:$set_arpgw