1#!/bin/sh 2# 3# Copyright (C) 2011 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# 18# Set the ARP gateway. 19 20FLAGS_HELP="Usage: 21 22 $(basename $0) 23 24or 25 26 $(basename $0) [true | false] 27" 28 29FLIMFLAM=org.chromium.flimflam 30IMANAGER=$FLIMFLAM.Manager 31 32usage() { 33 echo "$*" 34 echo 35 echo $FLAGS_HELP 36 exit 1 37} 38 39dbus () { 40 local obj=$1 41 local meth=$2 42 shift 2 43 44 dbus-send --system --print-reply --fixed --dest=$FLIMFLAM "$obj" "$meth" "$@" 45} 46 47get_manager () { 48 dbus / $IMANAGER.GetProperties | sed -n "/$1/s/.* //p" 49} 50 51display_arpgw () { 52 local arpgw=$(get_manager ArpGateway) 53 54 if [ -n "$arpgw" ] ; then 55 echo "Current Gateway ARP setting: " $arpgw 56 exit 0 57 fi 58 59 echo "This Flimflam instance does not support ArpGateway" 60 exit 0 61} 62 63if [ $# -lt 1 ]; then 64 display_arpgw 65fi 66 67set_arpgw=$1 68 69if [ $set_arpgw != false -a $set_arpgw != true ] ; then 70 usage "Argument must be 'true' or 'false'" 71fi 72 73dbus / $IMANAGER.SetProperty string:"ArpGateway" variant:boolean:$set_arpgw 74