projects
/
openwrt
/
svn-archive
/
archive.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
[package] add mac-to-devinfo (#5373)
[openwrt/svn-archive/archive.git]
/
net
/
mac-to-devinfo
/
files
/
ip-to-devinfo
1
#!/bin/sh
2
3
ARP
=
arp
4
MACTODEV
=
mac-to-devinfo
5
6
IP
=
$1
7
8
if
[
-z
"
$IP
"
];
then
9
echo
"Must specify IP address"
10
fi
11
12
if
[ !
-x
"$(which
$ARP
)"
];
then
13
do_arp
() {
14
cat
/
proc
/
net
/
arp
15
}
16
ARPMACFIELD
=
4
17
else
18
do_arp
() {
19
$ARP
-n
20
}
21
ARPMACFIELD
=
3
22
fi
23
24
ping
-q -c
2
$IP
>/
dev
/
null
25
MAC
=
$
(
do_arp|
grep
"
$IP
"
|
tr
-s
\ | cut
-f
$ARPMACFIELD
-d
\
)
26
27
$MACTODEV $MAC
28
29