-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnet-functions
More file actions
30 lines (25 loc) · 1.04 KB
/
net-functions
File metadata and controls
30 lines (25 loc) · 1.04 KB
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
# Filename: net-functions
# Purpose: network related functions for use in shellscripts
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
################################################################################
defaultGWDev() {
# ip r s | awk '/^default/ {print $5}'
route -en | awk '/^0.0.0.0/ {print $8}'
}
getLanDevices() {
ignore="vmnet lo sit $(brctl show | awk '{ if(NR >1 ) print $1 }' | xargs)"
filter=$(for mask in $ignore; do echo -n '&& $1 !~ /^'$mask/; done)
awk 'FS=":" {gsub(" ", ""); if(NR>2 '"$filter"' ) print $1 | "sort" } ' /proc/net/dev
}
getWlanDevices() {
awk 'FS=":" {gsub(" ", ""); if(NR>2 ) print $1 | "sort" } ' /proc/net/wireless
}
# getLanDriver deviceName
getLanDriver() {
if [ -e /sys/class/net/$1/device/driver ] ; then
basename $(readlink /sys/class/net/$1/device/driver)
fi
}
## END OF FILE #################################################################