Home | History | Annotate | Download | only in bin
      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 
     20 FLAGS_HELP="Usage:
     21 
     22   $(basename $0)
     23 
     24 or
     25 
     26   $(basename $0) [true | false]
     27 "
     28 
     29 FLIMFLAM=org.chromium.flimflam
     30 IMANAGER=$FLIMFLAM.Manager
     31 
     32 usage() {
     33   echo "$*"
     34   echo
     35   echo $FLAGS_HELP
     36   exit 1
     37 }
     38 
     39 dbus () {
     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 
     47 get_manager () {
     48   dbus / $IMANAGER.GetProperties | sed -n "/$1/s/.* //p"
     49 }
     50 
     51 display_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 
     63 if [ $# -lt 1 ]; then
     64     display_arpgw
     65 fi
     66 
     67 set_arpgw=$1
     68 
     69 if [ $set_arpgw != false -a $set_arpgw != true ] ; then
     70     usage "Argument must be 'true' or 'false'"
     71 fi
     72 
     73 dbus / $IMANAGER.SetProperty string:"ArpGateway" variant:boolean:$set_arpgw
     74