/[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.7 - (hide annotations) (download) (as text)
Thu Dec 22 19:55:49 2005 UTC (8 years, 7 months ago) by jkt
Branch: MAIN
Changes since 1.6: +22 -22 lines
File MIME type: application/xml
#116267, hb-net-*: adding <c>s, <path>s, proper capitalization,...

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

  ViewVC Help
Powered by ViewVC 1.1.20