/[gentoo]/xml/htdocs/doc/en/handbook/hb-net-functions.xml
Gentoo

Contents of /xml/htdocs/doc/en/handbook/hb-net-functions.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download) (as text)
Wed Mar 7 01:00:20 2007 UTC (7 years, 4 months ago) by nightmorph
Branch: MAIN
Changes since 1.9: +3 -11 lines
File MIME type: application/xml
mii-tool is deprecated, thanks to robbat2 & kingtaco for pointing it out on IRC

1 swift 1.1 <?xml version="1.0" encoding="UTF-8"?>
2     <!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3    
4     <!-- The content of this document is licensed under the CC-BY-SA license -->
5 swift 1.2 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6 swift 1.1
7 nightmorph 1.10 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-functions.xml,v 1.9 2006/10/28 09:17:55 neysx Exp $ -->
8 neysx 1.5
9 swift 1.1 <sections>
10    
11 neysx 1.9 <abstract>
12     If you're feeling adventurous, you can add your own functions to networking.
13     </abstract>
14    
15 nightmorph 1.10 <version>7.1</version>
16     <date>2007-03-06</date>
17 swift 1.1
18     <section>
19     <title>Standard function hooks</title>
20     <body>
21    
22     <p>
23 jkt 1.7 Four functions can be defined which will be called surrounding the
24     <c>start</c>/<c>stop</c> operations. The functions are called with the
25     interface name first so that one function can control multiple adapters.
26 swift 1.1 </p>
27    
28     <p>
29 jkt 1.7 The return values for the <c>preup()</c> and <c>predown()</c> functions should
30     be 0 (success) to indicate that configuration or deconfiguration of the
31     interface can continue. If <c>preup()</c> returns a non-zero value, then
32     interface configuration will be aborted. If <c>predown()</c> returns a non-zero
33     value, then the interface will not be allowed to continue deconfiguration.
34 swift 1.1 </p>
35    
36     <p>
37 jkt 1.7 The return values for the <c>postup()</c> and <c>postdown()</c> functions are
38     ignored since there's nothing to do if they indicate failure.
39 swift 1.1 </p>
40    
41     <p>
42 jkt 1.6 <c>${IFACE}</c> is set to the interface being brought up/down. <c>${IFVAR}</c>
43     is <c>${IFACE}</c> converted to variable name bash allows.
44 swift 1.1 </p>
45    
46     <pre caption="pre/post up/down function examples">
47     preup() {
48 swift 1.4 <comment># Test for link on the interface prior to bringing it up. This
49     # only works on some network adapters and requires the ethtool
50     # package to be installed.</comment>
51     if ethtool ${IFACE} | grep -q 'Link detected: no'; then
52     ewarn "No link on ${IFACE}, aborting configuration"
53     return 1
54     fi
55 swift 1.1
56 swift 1.4 <comment># Remember to return 0 on success</comment>
57     return 0
58 swift 1.1 }
59    
60     predown() {
61 swift 1.4 <comment># The default in the script is to test for NFS root and disallow
62     # downing interfaces in that case. Note that if you specify a
63     # predown() function you will override that logic. Here it is, in
64     # case you still want it...</comment>
65     if is_net_fs /; then
66     eerror "root filesystem is network mounted -- can't stop ${IFACE}"
67     return 1
68     fi
69 swift 1.1
70 swift 1.4 <comment># Remember to return 0 on success</comment>
71     return 0
72 swift 1.1 }
73    
74     postup() {
75 swift 1.4 <comment># This function could be used, for example, to register with a
76     # dynamic DNS service. Another possibility would be to
77     # send/receive mail once the interface is brought up.</comment>
78 swift 1.1 return 0
79     }
80    
81     postdown() {
82 swift 1.4 <comment># This function is mostly here for completeness... I haven't
83     # thought of anything nifty to do with it yet ;-)</comment>
84     return 0
85 swift 1.1 }
86     </pre>
87    
88     </body>
89     </section>
90     <section>
91     <title>Wireless Tools function hooks</title>
92     <body>
93    
94     <note>
95     This will not work with WPA Supplicant - but the <c>${ESSID}</c> and
96 jkt 1.7 <c>${ESSIDVAR}</c> variables are available in the <c>postup()</c> function.
97 swift 1.1 </note>
98    
99     <p>
100 jkt 1.6 Two functions can be defined which will be called surrounding the associate
101     function. The functions are called with the interface name first so that one
102     function can control multiple adapters.
103 swift 1.1 </p>
104    
105     <p>
106 jkt 1.7 The return values for the <c>preassociate()</c> function should be 0 (success)
107     to indicate that configuration or deconfiguration of the interface can continue.
108     If <c>preassociate()</c> returns a non-zero value, then interface configuration
109     will be aborted.
110 swift 1.1 </p>
111    
112     <p>
113 jkt 1.7 The return value for the <c>postassociate()</c> function is ignored since
114     there's nothing to do if it indicates failure.
115 swift 1.1 </p>
116    
117     <p>
118 swift 1.3 <c>${ESSID}</c> is set to the exact ESSID of the AP you're connecting to.
119 jkt 1.6 <c>${ESSIDVAR}</c> is <c>${ESSID}</c> converted to variable name bash allows.
120 swift 1.1 </p>
121    
122     <pre caption="pre/post association functions">
123     preassociate() {
124 swift 1.4 <comment># The below adds two configuration variables leap_user_ESSID
125     # and leap_pass_ESSID. When they are both configured for the ESSID
126     # being connected to then we run the CISCO LEAP script</comment>
127    
128     local user pass
129     eval user=\"\$\{leap_user_${ESSIDVAR}\}\"
130     eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\"
131    
132     if [[ -n ${user} &amp;&amp; -n ${pass} ]]; then
133     if [[ ! -x /opt/cisco/bin/leapscript ]]; then
134     eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils"
135     return 1
136     fi
137     einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\""
138     if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then
139     ewarn "Login Failed for ${user}"
140     return 1
141     fi
142     fi
143 swift 1.1
144 swift 1.4 return 0
145 swift 1.1 }
146    
147     postassociate() {
148 swift 1.4 <comment># This function is mostly here for completeness... I haven't
149     # thought of anything nifty to do with it yet ;-)</comment>
150 swift 1.1
151 swift 1.4 return 0
152 swift 1.1 }
153     </pre>
154    
155     <note>
156 jkt 1.7 <c>${ESSID}</c> and <c>${ESSIDVAR}</c> are unavailable in <c>predown()</c> and
157     <c>postdown()</c> functions.
158 swift 1.1 </note>
159    
160     </body>
161     </section>
162    
163     </sections>

  ViewVC Help
Powered by ViewVC 1.1.20