/[baselayout]/branches/rc-scripts-1_6/net-scripts/net.modules.d/macchanger
Gentoo

Contents of /branches/rc-scripts-1_6/net-scripts/net.modules.d/macchanger

Parent Directory Parent Directory | Revision Log Revision Log


Revision 549 - (show annotations) (download)
Tue Sep 14 16:49:40 2004 UTC (13 years, 11 months ago) by agriffis
Original Path: trunk/net-scripts/net.modules.d/macchanger
File size: 2303 byte(s)
update to 0.6.4 from Roy

1 # macchanger module for net-scripts
2 # Version 0.6.4
3 # Copyright (c) 2004 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License V2
5 # Contributed by Roy "UberLord" Marples (uberlord@rsm.demon.co.uk)
6
7 # char* macchanger_provides(void)
8 #
9 # Returns a string to change module definition for starting up
10 macchanger_provides() {
11 echo "macchanger"
12 }
13
14 # void macchanger_depend(void)
15 #
16 # Sets up the dependancies for the module
17 macchanger_depend() {
18 before interface wireless
19 need interface
20 }
21
22 # bool macchanger_check_installed(void)
23 #
24 # Returns 1 if macchanger is installed, otherwise 0
25 macchanger_check_installed() {
26 [[ -x /sbin/macchanger ]] && return 0
27 [[ ${1} == true ]] && eerror "For changing MAC addresses, emerge net-analyzer/macchanger"
28 return 1
29 }
30
31 # bool macchanger_check_depends(void)
32 #
33 # Checks to see if we have the needed functions
34 macchanger_check_depends() {
35 local f
36
37 for f in interface_get_mac_address; do
38 [[ $(type -t ${f}) == function ]] && continue
39 eerror "macchanger: missing required function ${f}\n"
40 return 1
41 done
42
43 return 0
44 }
45
46 # bool macchanger_pre_start(char *iface)
47 #
48 # Configures the MAC address for iface
49 macchanger_pre_start() {
50 local iface=${1} mac opts e
51
52 eval mac=\"\$\{mac_${iface}\}\"
53 [[ -z ${mac} ]] && return 0
54
55 case "${mac}" in
56 # specific mac-addr, i wish there were a shorter way to specify this
57 [0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]) opts="${opts} --mac=${mac}" ;;
58
59 # increment MAC address, default macchanger behavior
60 increment) opts="${opts}" ;;
61
62 # randomize just the ending bytes
63 random-ending) opts="${opts} -e" ;;
64
65 # keep the same kind of physical layer (eg fibre, copper)
66 random-samekind) opts="${opts} -a" ;;
67
68 # randomize to any known vendor of any physical layer type
69 random-anykind) opts="${opts} -A" ;;
70
71 # fully random bytes
72 random-full) opts="${opts} -r" ;;
73
74 # default case is just to pass on all the options
75 *) opts="${opts} ${mac}" ;;
76 esac
77
78 e=$( /sbin/macchanger ${opts} ${IFACE} )
79 if [[ -n ${e} ]]; then
80 eerror "Failed to set MAC address"
81 return 1
82 fi
83
84 mac=$( interface_get_mac_address ${iface} )
85 einfo " MAC address for ${iface} changed to ${mac}"
86
87 return 0 #important
88 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20