| #!/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. |
| " |
| |
| FLIMFLAM=org.chromium.flimflam |
| IMANAGER=$FLIMFLAM.Manager |
| |
| usage() { |
| echo "$*" |
| 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 |
| |
| 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 |
| } |
| |
| if [ $# -lt 1 ]; then |
| display_arpgw |
| fi |
| |
| set_arpgw="$1" |
| |
| if [ "${set_arpgw}" != false ] && [ "${set_arpgw}" != true ]; then |
| usage "Argument must be 'true' or 'false'" |
| fi |
| |
| dbus / $IMANAGER.SetProperty string:"ArpGateway" variant:boolean:"${set_arpgw}" |