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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.11 Revision 1.12
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> 2<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3 3
4<!-- The content of this document is licensed under the CC-BY-SA license --> 4<!-- The content of this document is licensed under the CC-BY-SA license -->
5<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 5<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6 6
7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-functions.xml,v 1.11 2007/05/07 18:11:41 nightmorph Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-functions.xml,v 1.12 2010/05/14 22:12:57 nightmorph Exp $ -->
8 8
9<sections> 9<sections>
10 10
11<abstract> 11<abstract>
12If you're feeling adventurous, you can add your own functions to networking. 12If you're feeling adventurous, you can add your own functions to networking.
13</abstract> 13</abstract>
14 14
15<version>8.0</version> 15<version>8.1</version>
16<date>2007-05-07</date> 16<date>2010-05-14</date>
17 17
18<section> 18<section>
19<title>Standard function hooks</title> 19<title>Standard function hooks</title>
20<body> 20<body>
21 21
22<p> 22<p>
23Four functions can be defined which will be called surrounding the 23Four functions can be defined in <path>/etc/conf.d/net</path> which will be
24<c>start</c>/<c>stop</c> operations. The functions are called with the 24called surrounding the <c>start</c>/<c>stop</c> operations. The functions are
25interface name first so that one function can control multiple adapters. 25called with the interface name first so that one function can control multiple
26adapters.
26</p> 27</p>
27 28
28<p> 29<p>
29The return values for the <c>preup()</c> and <c>predown()</c> functions should 30The return values for the <c>preup()</c> and <c>predown()</c> functions should
30be 0 (success) to indicate that configuration or deconfiguration of the 31be 0 (success) to indicate that configuration or deconfiguration of the
41<p> 42<p>
42<c>${IFACE}</c> is set to the interface being brought up/down. <c>${IFVAR}</c> 43<c>${IFACE}</c> is set to the interface being brought up/down. <c>${IFVAR}</c>
43is <c>${IFACE}</c> converted to variable name bash allows. 44is <c>${IFACE}</c> converted to variable name bash allows.
44</p> 45</p>
45 46
46<pre caption="pre/post up/down function examples"> 47<pre caption="pre/post up/down function examples in /etc/conf.d/net">
47preup() { 48preup() {
48 <comment># Test for link on the interface prior to bringing it up. This 49 <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 # only works on some network adapters and requires the ethtool
50 # package to be installed.</comment> 51 # package to be installed.</comment>
51 if ethtool ${IFACE} | grep -q 'Link detected: no'; then 52 if ethtool ${IFACE} | grep -q 'Link detected: no'; then
83 # thought of anything nifty to do with it yet ;-)</comment> 84 # thought of anything nifty to do with it yet ;-)</comment>
84 return 0 85 return 0
85} 86}
86</pre> 87</pre>
87 88
89<note>
90For more information on writing your own functions, please read
91<path>/etc/conf.d/net.example</path>.
92</note>
93
88</body> 94</body>
89</section> 95</section>
90<section> 96<section>
91<title>Wireless Tools function hooks</title> 97<title>Wireless Tools function hooks</title>
92<body> 98<body>
95This will not work with WPA Supplicant - but the <c>${ESSID}</c> and 101This will not work with WPA Supplicant - but the <c>${ESSID}</c> and
96<c>${ESSIDVAR}</c> variables are available in the <c>postup()</c> function. 102<c>${ESSIDVAR}</c> variables are available in the <c>postup()</c> function.
97</note> 103</note>
98 104
99<p> 105<p>
100Two functions can be defined which will be called surrounding the associate 106Two functions can be defined in <path>/etc/conf.d/net</path> which will be
101function. The functions are called with the interface name first so that one 107called surrounding the associate function. The functions are called with the
102function can control multiple adapters. 108interface name first so that one function can control multiple adapters.
103</p> 109</p>
104 110
105<p> 111<p>
106The return values for the <c>preassociate()</c> function should be 0 (success) 112The return values for the <c>preassociate()</c> function should be 0 (success)
107to indicate that configuration or deconfiguration of the interface can continue. 113to indicate that configuration or deconfiguration of the interface can continue.
114there's nothing to do if it indicates failure. 120there's nothing to do if it indicates failure.
115</p> 121</p>
116 122
117<p> 123<p>
118<c>${ESSID}</c> is set to the exact ESSID of the AP you're connecting to. 124<c>${ESSID}</c> is set to the exact ESSID of the AP you're connecting to.
119<c>${ESSIDVAR}</c> is <c>${ESSID}</c> converted to variable name bash allows. 125<c>${ESSIDVAR}</c> is <c>${ESSID}</c> converted to a variable name bash allows.
120</p> 126</p>
121 127
122<pre caption="pre/post association functions"> 128<pre caption="pre/post association functions in /etc/conf.d/net">
123preassociate() { 129preassociate() {
124 <comment># The below adds two configuration variables leap_user_ESSID 130 <comment># The below adds two configuration variables leap_user_ESSID
125 # and leap_pass_ESSID. When they are both configured for the ESSID 131 # and leap_pass_ESSID. When they are both configured for the ESSID
126 # being connected to then we run the CISCO LEAP script</comment> 132 # being connected to then we run the CISCO LEAP script</comment>
127 133
155<note> 161<note>
156<c>${ESSID}</c> and <c>${ESSIDVAR}</c> are unavailable in <c>predown()</c> and 162<c>${ESSID}</c> and <c>${ESSIDVAR}</c> are unavailable in <c>predown()</c> and
157<c>postdown()</c> functions. 163<c>postdown()</c> functions.
158</note> 164</note>
159 165
166<note>
167For more information on writing your own functions, please read
168<path>/etc/conf.d/net.example</path>.
169</note>
170
160</body> 171</body>
161</section> 172</section>
162 173
163</sections> 174</sections>

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20