#!/bin/bash # IOSLIB version 1.0.3 (Hua-hua) test. # Copyright (C) 2006 Matous Jan Fialka. # Released under the terms of GNU/GPL. source 'ioslib.inc' interface() { if IOS_IsNeg then echo '# Negation of section not allowed.' return 1 fi if IOS_InSameSect interface then echo '# Already been in interface section.' return 1 fi if ! IOS_EqSectName ROOT then echo '# Must be run from the root section.' return 1 fi if [[ $# != 1 ]] then echo "# One argument expected; $# given." return 1 fi IOS_EnterSect interface IOS_SetVar eth $1 echo "ip link set up dev $(IOS_GetVar eth)" return 0 } address() { if ! IOS_EqSectName interface then echo '# Must be run from the interface section.' return 1 fi if [[ $# != 2 ]] then echo "# One argument expected (IP address and prefix); $# given." return 1 fi local ACTION='add' if IOS_IsNeg then ACTION='delete' fi echo "ip address $ACTION $1/$2 brd + dev $(IOS_GetVar eth)" return 0 } route() { if ! IOS_EqSectName ROOT interface then echo '# Must be run from the ROOT section.' return 1 fi if [[ $# != 3 ]] then echo "# One argument expected (IP address, prefix and destination); $# given." return 1 fi local ACTION='add' if IOS_IsNeg then ACTION='delete' fi local VIA='via' if [[ $3 = eth* ]] then VIA='dev' fi local DEV= if IOS_EqSectName interface then DEV="dev $(IOS_GetVar eth)" fi echo "ip route $ACTION $1/$2 $VIA $3 $DEV" return 0 } IOS_RegFun interface address IOS_RegFun route IOS_Source < test-iproute.STDIN