PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/external/bsd/bind/dist/bin/tests/system/ifconfig.sh

https://gitlab.com/storedmirrors/minix
Shell | 234 lines | 195 code | 12 blank | 27 comment | 7 complexity | a0b748f196d6b314dd52bcee3142cddf MD5 | raw file
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2004, 2007-2010, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
  4. # Copyright (C) 2000-2003 Internet Software Consortium.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  11. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  12. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  14. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  15. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. # PERFORMANCE OF THIS SOFTWARE.
  17. # Id: ifconfig.sh,v 1.59 2010/06/11 23:46:49 tbox Exp
  18. #
  19. # Set up interface aliases for bind9 system tests.
  20. #
  21. # IPv4: 10.53.0.{1..8} RFC 1918
  22. # IPv6: fd92:7065:b8e:ffff::{1..8} ULA
  23. #
  24. config_guess=""
  25. for f in ./config.guess ../../../config.guess
  26. do
  27. if test -f $f
  28. then
  29. config_guess=$f
  30. fi
  31. done
  32. if test "X$config_guess" = "X"
  33. then
  34. cat <<EOF >&2
  35. $0: must be run from the top level source directory or the
  36. bin/tests/system directory
  37. EOF
  38. exit 1
  39. fi
  40. # If running on hp-ux, don't even try to run config.guess.
  41. # It will try to create a temporary file in the current directory,
  42. # which fails when running as root with the current directory
  43. # on a NFS mounted disk.
  44. case `uname -a` in
  45. *HP-UX*) sys=hpux ;;
  46. *) sys=`sh $config_guess` ;;
  47. esac
  48. case "$2" in
  49. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) base=$2;;
  50. *) base="1"
  51. esac
  52. case "$3" in
  53. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) base6=$3;;
  54. *) base6=$base
  55. esac
  56. case "$1" in
  57. start|up)
  58. for ns in 1 2 3 4 5 6 7 8
  59. do
  60. if test -n "$base"
  61. then
  62. int=`expr $ns + $base - 1`
  63. else
  64. int=$ns
  65. fi
  66. if test -n "$base6"
  67. then
  68. int6=`expr $ns + $base6 - 1`
  69. else
  70. int6=$ns
  71. fi
  72. case "$sys" in
  73. *-pc-solaris2.5.1)
  74. ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up
  75. ;;
  76. *-sun-solaris2.[6-7])
  77. ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up
  78. ;;
  79. *-*-solaris2.[8-9]|*-*-solaris2.1[0-9])
  80. /sbin/ifconfig lo0:$int plumb
  81. /sbin/ifconfig lo0:$int 10.53.0.$ns up
  82. if test -n "$int6"
  83. then
  84. /sbin/ifconfig lo0:$int6 inet6 plumb
  85. /sbin/ifconfig lo0:$int6 \
  86. inet6 fd92:7065:b8e:ffff::$ns up
  87. fi
  88. ;;
  89. *-*-linux*)
  90. ifconfig lo:$int 10.53.0.$ns up netmask 255.255.255.0
  91. ifconfig lo inet6 add fd92:7065:b8e:ffff::$ns/64
  92. ;;
  93. *-unknown-freebsd*)
  94. ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff
  95. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  96. ;;
  97. *-unknown-netbsd*)
  98. ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0
  99. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  100. ;;
  101. *-unknown-openbsd*)
  102. ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0
  103. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  104. ;;
  105. *-*-bsdi[3-5].*)
  106. ifconfig lo0 add 10.53.0.$ns netmask 255.255.255.0
  107. ;;
  108. *-dec-osf[4-5].*)
  109. ifconfig lo0 alias 10.53.0.$ns
  110. ;;
  111. *-sgi-irix6.*)
  112. ifconfig lo0 alias 10.53.0.$ns
  113. ;;
  114. *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
  115. ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff
  116. ;;
  117. *-ibm-aix4.*|*-ibm-aix5.*)
  118. ifconfig lo0 alias 10.53.0.$ns
  119. ifconfig lo0 inet6 alias -dad fd92:7065:b8e:ffff::$ns/64
  120. ;;
  121. hpux)
  122. ifconfig lo0:$int 10.53.0.$ns netmask 255.255.255.0 up
  123. ifconfig lo0:$int inet6 fd92:7065:b8e:ffff::$ns up
  124. ;;
  125. *-sco3.2v*)
  126. ifconfig lo0 alias 10.53.0.$ns
  127. ;;
  128. *-darwin*)
  129. ifconfig lo0 alias 10.53.0.$ns
  130. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  131. ;;
  132. *)
  133. echo "Don't know how to set up interface. Giving up."
  134. exit 1
  135. esac
  136. done
  137. ;;
  138. stop|down)
  139. for ns in 8 7 6 5 4 3 2 1
  140. do
  141. if test -n "$base"
  142. then
  143. int=`expr $ns + $base - 1`
  144. else
  145. int=$ns
  146. fi
  147. if test -n "$base6"
  148. then
  149. int6=`expr $ns + $base6 - 1`
  150. else
  151. int6=$ns
  152. fi
  153. case "$sys" in
  154. *-pc-solaris2.5.1)
  155. ifconfig lo0:$int 0.0.0.0 down
  156. ;;
  157. *-sun-solaris2.[6-7])
  158. ifconfig lo0:$int 10.53.0.$ns down
  159. ;;
  160. *-*-solaris2.[8-9]|*-*-solaris2.1[0-9])
  161. ifconfig lo0:$int 10.53.0.$ns down
  162. ifconfig lo0:$int 10.53.0.$ns unplumb
  163. if test -n "$int6"
  164. then
  165. ifconfig lo0:$int6 inet6 down
  166. ifconfig lo0:$int6 inet6 unplumb
  167. fi
  168. ;;
  169. *-*-linux*)
  170. ifconfig lo:$int 10.53.0.$ns down
  171. ifconfig lo inet6 del fd92:7065:b8e:ffff::$ns/64
  172. ;;
  173. *-unknown-freebsd*)
  174. ifconfig lo0 10.53.0.$ns delete
  175. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  176. ;;
  177. *-unknown-netbsd*)
  178. ifconfig lo0 10.53.0.$ns delete
  179. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  180. ;;
  181. *-unknown-openbsd*)
  182. ifconfig lo0 10.53.0.$ns delete
  183. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  184. ;;
  185. *-*-bsdi[3-5].*)
  186. ifconfig lo0 remove 10.53.0.$ns
  187. ;;
  188. *-dec-osf[4-5].*)
  189. ifconfig lo0 -alias 10.53.0.$ns
  190. ;;
  191. *-sgi-irix6.*)
  192. ifconfig lo0 -alias 10.53.0.$ns
  193. ;;
  194. *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
  195. ifconfig lo0 -alias 10.53.0.$ns
  196. ;;
  197. *-ibm-aix4.*|*-ibm-aix5.*)
  198. ifconfig lo0 delete 10.53.0.$ns
  199. ifconfig lo0 delete inet6 fd92:7065:b8e:ffff::$ns/64
  200. ;;
  201. hpux)
  202. ifconfig lo0:$int 0.0.0.0
  203. ifconfig lo0:$int inet6 ::
  204. ;;
  205. *-sco3.2v*)
  206. ifconfig lo0 -alias 10.53.0.$ns
  207. ;;
  208. *darwin*)
  209. ifconfig lo0 -alias 10.53.0.$ns
  210. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  211. ;;
  212. *)
  213. echo "Don't know how to destroy interface. Giving up."
  214. exit 1
  215. esac
  216. done
  217. ;;
  218. *)
  219. echo "Usage: $0 { up | down } [base]"
  220. exit 1
  221. esac