/[baselayout]/trunk/net.BSD/ifconfig.sh
Gentoo

Diff of /trunk/net.BSD/ifconfig.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2793 Revision 2794
5 program /sbin/ifconfig 5 program /sbin/ifconfig
6 provide interface 6 provide interface
7} 7}
8 8
9_exists() { 9_exists() {
10 # Only FreeBSD sees to have /dev/net .... is there something
11 # other than ifconfig we can use for the others?
12 if [ -d /dev/net ] ; then
10 [ -e /dev/net/"${IFACE}" ] 13 [ -e /dev/net/"${IFACE}" ]
14 else
15 ifconfig "${IFACE}" >/dev/null 2>&1
16 fi
11} 17}
12 18
13_get_mac_address() { 19_get_mac_address() {
14 local mac=$(LC_ALL=C ifconfig "${IFACE}" | \ 20 local mac=$(LC_ALL=C ifconfig "${IFACE}" | \
15 sed -n -e 's/^[[:space:]]*ether \(..:..:..:..:..:..\).*/\1/p') 21 sed -n -e 's/^[[:space:]]*ether \(..:..:..:..:..:..\).*/\1/p')
31_down () { 37_down () {
32 ifconfig "${IFACE}" down 38 ifconfig "${IFACE}" down
33} 39}
34 40
35_ifindex() { 41_ifindex() {
36 local x= 42 local x= i=1
43 case "${RC_UNAME}" in
44 FreeBSD|DragonFly)
37 for x in /dev/net[0-9]* ; do 45 for x in /dev/net[0-9]* ; do
38 if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then 46 if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then
39 echo "${x#/dev/net}" 47 echo "${x#/dev/net}"
40 return 0 48 return 0
41 fi 49 fi
42 done 50 done
51 ;;
52 default)
53 for x in $(ifconfig -a | sed -n -e 's/^\([^[:space:]]*\):.*/\1/p') ; do
54 if [ "${x}" = "${IFACE}" ] ; then
55 echo "${i}"
56 return 0
57 fi
58 i=$((${i} + 1))
59 done
60 ;;
61 esac
43 return 1 62 return 1
44} 63}
45 64
46_is_wireless() { 65_is_wireless() {
47 LC_ALL=C ifconfig "${IFACE}" 2>/dev/null | \ 66 LC_ALL=C ifconfig "${IFACE}" 2>/dev/null | \
61_add_address() { 80_add_address() {
62 if [ "${metric:-0}" != "0" ] ; then 81 if [ "${metric:-0}" != "0" ] ; then
63 set -- "$@" metric ${metric} 82 set -- "$@" metric ${metric}
64 fi 83 fi
65 84
85 # ifconfig doesn't like CIDR addresses
86 case "${RC_UNAME}" in
87 NetBSD|OpenBSD)
88 local ip="${1%%/*}" cidr="${1##*/}" netmask=
89 if [ -n "${cidr}" -a "${cidr}" != "${ip}" ]; then
90 netmask="$(_cidr2netmask "${cidr}")"
91 shift
92 set -- "${ip}" netmask "${netmask}" "$@"
93 fi
94 ;;
95 esac
96
66 case "$@" in 97 case "$@" in
67 *:*) ifconfig "${IFACE}" inet6 add "$@" ;; 98 *:*) ifconfig "${IFACE}" inet6 "$@" ;;
68 *) ifconfig "${IFACE}" add "$@" ;; 99 *) ifconfig "${IFACE}" "$@" ;;
69 esac 100 esac
70} 101}
71 102
72_add_route() { 103_add_route() {
73 if [ $# -gt 3 ] ; then 104 if [ $# -gt 3 ] ; then

Legend:
Removed from v.2793  
changed lines
  Added in v.2794

  ViewVC Help
Powered by ViewVC 1.1.20