blob: bf425ef688d92c5339257d17316856994ce4d7d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!/bin/sh
# $NetBSD: script2,v 1.2 2001/07/12 19:08:05 garbled Exp $
if [ "$1" = "4" ]; then
IPV4=`ifconfig $2 | grep 'inet ' | \
sed -e 's/inet \([0-9\.]*\) net.*/\1/'`
if [ -z "$IPV4" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
IPV4=`cat /etc/ifconfig.$2 | \
sed -e 's/[a-zA-z ]*\([0-9\.]*\) .*/\1/'`
else
IPV4=" "
fi
fi
echo $IPV4
exit 0
fi
if [ "$1" = "n" ]; then
NETMASK=`ifconfig $2 | grep 'inet ' | \
sed -e 's/.*netmask \([0-9a-fx\.]*\) broad.*/\1/'`
if [ -z "$NETMASK" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
NETMASK=`cat /etc/ifconfig.$2 | grep netmask | \
sed -e 's/.*netmask *\([0-9a-fx\.]*\).*/\1/'`
else
NETMASK=" "
fi
fi
echo $NETMASK
exit 0
fi
if [ "$1" = "b" ]; then
BROAD=`ifconfig $2 | grep 'inet ' | \
sed -e 's/.*broadcast \([0-9a-fx\.]*\)/\1/'`
if [ -z "$BROAD" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
BROAD=`cat /etc/ifconfig.$2 | grep broadcast | \
sed -e 's/.*broadcast *\([0-9a-fx\.]*\).*/\1/'`
else
BROAD=" "
fi
fi
echo $BROAD
exit 0
fi
if [ "$1" = "m" ]; then
MEDIA=`ifconfig $2 | grep 'media: ' | \
sed -e 's/.*media: Ethernet \([0-9a-zA-z]*\) .*/\1/'`
if [ -z "$MEDIA" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
MEDIA=`cat /etc/ifconfig.$2 | grep media | \
sed -e 's/.*media *\([0-9a-zA-z]*\) .*/\1/'`
fi
fi
if [ -z $MEDIA ]; then
ifconfig -m $2 | grep 'media ' | awk '{print $2}' | sort | uniq
else
echo $MEDIA
ifconfig -m $2 | grep -v $MEDIA | grep 'media ' | \
awk '{print $2}' | sort | uniq
fi
exit 0
fi
if [ "$1" = "o" ]; then
OPT=`ifconfig -m $2 | grep 'media: ' | awk '{print $4}'`
if [ -z "$OPT" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
OPT=`cat /etc/ifconfig.$2 | grep mediaopt | \
sed -e 's/.*mediaopt *\([a-zA-Z0-9-]*\) *.*/\1/'`
fi
fi
if [ -z "$OPT" ]; then
echo "none"
ifconfig -m $2 | grep 'mediaopt ' | awk '{print $4}' | \
sort | uniq
else
echo $OPT
ifconfig -m $2 | grep -v $OPT | grep 'mediaopt ' | \
awk '{print $4}' | sort | uniq
echo "none"
fi
exit 0
fi
if [ "$1" = "met" ]; then
MET=`ifconfig $2 | grep 'metric ' | sed -e 's/.*metric \([0-9]*\) .*/\1/'`
if [ -z "$MET" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
MET=`cat /etc/ifconfig.$2 | grep metric | \
sed -e 's/.*metric *\([0-9]*\).*/\1/'`
else
MET="0"
fi
if [ -z "$MET" ]; then
MET="0"
fi
fi
echo $MET
exit 0
fi
if [ "$1" = "mtu" ]; then
MTU=`ifconfig $2 | grep 'mtu ' | sed -e 's/.*mtu \([0-9]*\)/\1/'`
if [ -z "$MTU" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
MTU=`cat /etc/ifconfig.$2 | grep mtu | \
sed -e 's/.*mtu *\([0-9]*\).*/\1/'`
else
MTU="1500"
fi
fi
echo $MTU
exit 0
fi
if [ "$1" = "6" ]; then
IPV6=`ifconfig $2 | grep 'inet6 ' | \
sed -e 's/inet6 \([0-9:a-z%]*\) pre.*/\1/'`
if [ -z "$IPV6" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
IPV6=`cat /etc/ifconfig.$2 | grep 'inet6 ' | \
sed -e 's/inet6 \([0-9:a-z%]*\) .*/\1/'`
else
IPV6=" "
fi
fi
echo $IPV6
exit 0
fi
if [ "$1" = "pre" ]; then
PRE=`ifconfig $2 | grep 'inet6 ' | sed -e 's/.*prefixlen \([0-9]*\) .*/\1/'`
if [ -z "$PRE" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
PRE=`cat /etc/ifconfig.$2 | grep prefixlen | \
sed -e 's/.*prefixlen *\([0-9]*\).*/\1/'`
else
PRE="64"
fi
if [ -z "$PRE" ]; then
PRE="64"
fi
fi
echo $PRE
exit 0
fi
if [ "$1" = "i" ]; then
NWID=`ifconfig $2 | grep 'nwid ' | \
sed -f /usr/share/sushi/network/interfaces/interface/nwid.sed`
if [ -z "$NWID" ]; then
if [ -f "/etc/ifconfig.$2" ]; then
NWID=`cat /etc/ifconfig.$2 | grep nwid | \
sed -f /usr/share/sushi/network/interfaces/interface/nwid.sed`
else
NWID=""
fi
fi
echo $NWID
exit 0
fi
echo ""
|