Debian Codegraph @

scripts/bin/drbl-get-netmask

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Authors: Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_ nchc org tw>
3 # License: GPL
4 # Description: Get the netmask of network card interface
5
6 # Load DRBL setting and functions
7 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
8
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10
11
12 ethx=$1
13 export LC_ALL=C
14
15 Usagescip-shell shell shell-project 0.0.0 Usage().() {
16 echoscip-shell system . . echo. "Get the netmask of network card interface"
17 echoscip-shell system . . echo. "Usage:"
18 echoscip-shell system . . echo. "$(basenamescip-shell system . . basename. $0) INTERFACE"
19 echoscip-shell system . . echo. "Ex: $(basenamescip-shell system . . basename. $0) eth0"
20 }
21
22 [scip-shell system . . `[`. -z "$ethx" ] && Usagescip-shell shell shell-project 0.0.0 Usage(). && exit 1
23 if ! LC_ALL=C ip link show dev $ethx >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
24 exit 1
25 fi
26 _cidr="$(LC_ALL=C ip addr show dev $ethx 2>/dev/nullscip-shell filesystem . . `/dev/null`. | awkscip-shell system . . awk. '/inet / {print $2}scip-shell filesystem . . `/inet / {print $2}`.' | cutscip-shell system . . cut. -d/ -f2 | headscip-shell system . . head. -n1)"
27 if [scip-shell system . . `[`. -n "$_cidr" ]; then
28 _val=$(( 0xffffffff ^ ((1 << (32 - _cidr)) - 1) ))
29 echoscip-shell system . . echo. "$(( (_val >> 24) & 255 )).$(( (_val >> 16) & 255 )).$(( (_val >> 8) & 255 )).$(( _val & 255 ))"
30 else
31 exit 1
32 fi
33 exit 0