3 : ${FAKE_IP_STATE:=${PWD}/var/fake-ip-state}
7 echo "ip stub command: \"$1\" not implemented"
19 rm -f "${FAKE_IP_STATE}/interfaces-down/${iface}"
22 mkdir -p "${FAKE_IP_STATE}/interfaces-down"
23 touch "${FAKE_IP_STATE}/interfaces-down/${iface}"
30 not_implemented "$1 $2"
41 while [ -n "$1" ] ; do
50 # For now assume this is always '+'.
51 if [ "$2" != "+" ] ; then
52 not_implemented "addr add ... brd $2 ..."
60 not_implemented "addr add ... $1 ..."
63 if [ -z "$dev" ] ; then
64 not_implemented "addr add (without dev)"
66 mkdir -p "${FAKE_IP_STATE}/addresses"
67 pf="${FAKE_IP_STATE}/addresses/${dev}-primary"
68 sf="${FAKE_IP_STATE}/addresses/${dev}-secondary"
69 # We could lock here... but we should be the only ones
70 # playing around here with these stubs.
71 if [ ! -f "$pf" ] ; then
73 elif grep -Fq "$local" "$pf" ; then
74 echo "RTNETLINK answers: File exists" >&2
76 elif [ -f "$sf" ] && grep -Fq "$local" "$sf" ; then
77 echo "RTNETLINK answers: File exists" >&2
87 while [ -n "$1" ] ; do
99 not_implemented "addr del ... $1 ..."
102 if [ -z "$dev" ] ; then
103 not_implemented "addr del (without dev)"
105 mkdir -p "${FAKE_IP_STATE}/addresses"
106 pf="${FAKE_IP_STATE}/addresses/${dev}-primary"
107 sf="${FAKE_IP_STATE}/addresses/${dev}-secondary"
108 # We could lock here... but we should be the only ones
109 # playing around here with these stubs.
110 if [ ! -f "$pf" ] ; then
111 echo "RTNETLINK answers: Cannot assign requested address" >&2
113 elif grep -Fq "$local" "$pf" ; then
114 # Remove primaries AND SECONDARIES.
116 elif [ -f "$sf" ] && grep -Fq "$local" "$sf" ; then
117 grep -Fv "$local" "$sf" >"${sf}.new"
120 echo "RTNETLINK answers: Cannot assign requested address" >&2
129 while [ -n "$1" ] ; do
134 # Do stupid things and stupid things will happen!
136 primary=true ; secondary=false ; shift
139 secondary=true ; primary=false ; shift
142 # Assume an interface name
147 if [ -z "$devices" ] ; then
148 # No device specified? Get all the primaries...
149 devices=$(ls "${FAKE_IP_STATE}/addresses/"*-primary 2>/dev/null | \
150 sed -e 's@.*/@@' -e 's@-primary$@@')
154 case "${local#*/}" in
156 brd="${local%.*}.255"
159 not_implemented "list ... fake bits other than 24: ${local#*/}"
164 pf="${FAKE_IP_STATE}/addresses/${dev}-primary"
165 sf="${FAKE_IP_STATE}/addresses/${dev}-secondary"
166 mac=$(echo $dev | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
168 ${n}: ${dev}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
169 link/ether ${mac} brd ff:ff:ff:ff:ff:ff
171 if $primary && [ -r "$pf" ] ; then
175 inet ${local} brd ${brd} scope global ${dev}
178 if $secondary && [ -r "$sf" ] ; then
179 while read local ; do
182 inet ${local} brd ${brd} scope global secondary ${dev}
187 valid_lft forever preferred_lft forever
192 for dev in $devices ; do
198 not_implemented "$1 $2"