📄 c-dll4.html
字号:
<dd><pre class="Code2"><b><a name="84665">PPP_OPTIONS pppOpt; /* PPP configuration options */ void routine () { pppOpt.flags = OPT_PASSIVE_MODE | OPT_NO_PAP | OPT_NO_CHAP | OPT_NO_VJ; pppOpt.lcp_echo_interval = "30"; pppOpt.lcp_echo_failure = "10"; pppInit (0, "/tyCo/1", "90.0.0.1", "90.0.0.10", 0, &pppOpt, NULL); }</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="93054">Setting PPP Options Using an Options File</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84679"> </a>PPP options are most conveniently set using an options file. There is one restriction: the options file must be readable by the target without there being an active PPP link. Therefore the target must either have a local disk or RAM disk or an additional network connection. For more information about using file systems, see <i class="title">VxWorks Programmer's Guide: Local File Systems</i>. </p><dd><p class="Body"><a name="84682"> </a>This configuration method can be used with either <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> or <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>. It also can be used to modify the selection of PPP options previously configured using configuration constants in <b class="file">config.h</b> or the option structure <b class="symbol_lc">PPP_OPTION</b>. </p><dd><p class="Body"><a name="84683"> </a>When using <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> to initialize PPP, define the configuration constant <b class="symbol_UC">PPP_OPTIONS_FILE</b> to be the absolute path name of the options file (<b class="symbol_UC">NULL</b> by default). When using <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>, pass in a character string that specifies the absolute path name of the options file. </p><dd><p class="Body"><a name="84685"> </a>The options file format is one option per line; comment lines begin with <b class="command">#</b>. For a description of option syntax, see the manual entry for <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>. </p><dd><p class="Body"><a name="84686"> </a>The following code fragment generates the same results as the code example in <a href="c-dll4.html#84650"><i class="title">Selecting PPP Options Using an Options Structure</i></a>. The difference is that the configuration options are obtained from a file rather than a structure. </p><dl class="margin"><dd><pre class="Code2"><b><a name="94235">pppFile = "mars:/tmp/ppp_options"; /* PPP config. options file */ void routine () { pppInit (0, "/tyCo/1", "90.0.0.1", "90.0.0.10", 0, NULL, pppFile); }</a></b></pre></dl><dd><p class="Body"><a name="94236"> </a>In this example, <b class="file">mars:/tmp/ppp_options</b> is a file that contains the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="94237">passive no_pap no_chap no_vj lcp_echo_interval 30 lcp_echo_failure 10</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84705">3.4.6 Using PPP</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84706"> </a>After it is configured and initialized, PPP attaches itself into the VxWorks TCP/IP stack at the driver (link) layer. After a PPP link has been established with the remote peer, all normal VxWorks IP networking facilities are available; the PPP connection is transparent to the user.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84708">Initializing a PPP Link</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84712"> </a>A PPP link is initialized by calls to either <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> or <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>. When either of these routines is invoked, the remote peer should be initialized. When a peer is running in passive mode, it must be initialized first (see <a href="c-dll4.html#84769"><i class="title">PPP Options</i></a>.)</p><dd><p class="Body"><a name="84717"> </a>The <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b>routine is in <b class="file">config/all/bootConfig.c</b> and <b class="file">src/config/usrNetwork.c</b>. There are four ways it can be called:</p><dd><p class="Body"><a name="84718"> </a>If the boot device is set to <b class="symbol_lc">ppp</b>, <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> is called as follows: </p></dl><dl class="margin"><ul class="DashSingle" type="circle"><li><a name="84720"> </a>From<b>( )</b><b class="file">bootConfig.c</b> when booting from boot ROMs. </li></ul><ul class="DashSingle" type="circle"><li><a name="84722"> </a>From <b class="file">usrNetwork.c</b> when booting from VxWorks boot code. </li></ul></dl><dl class="margin"><dd><p class="Body"><a name="84723"> </a>The PPP interface can also be initialized by calling <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b>:</p></dl><dl class="margin"><ul class="DashSingle" type="circle"><li><a name="84724"> </a>From the VxWorks shell.</li></ul><ul class="DashSingle" type="circle"><li><a name="84725"> </a>By user application code. </li></ul></dl><dl class="margin"><dd><p class="Body"><a name="84726"> </a>Use either syntax when calling <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b>:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84727">usrPPPInit ("bootDevice", unitNum, "localIPAddress", "remoteIPAddress") usrPPPInit ("bootDevice", unitNum, "localHostName", "remoteHostName")</a></b></pre></dl><dd><p class="Body"><a name="84729"> </a>You can use host names in <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> provided the hosts have been previously added to the host database. For example, you can call <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> in the following way:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84730">usrPPPInit ("ppp=/tyCo/1,38400", 1, "147.11.90.1", "147.11.90.199") </a></b></pre></dl><dd><p class="Body"><a name="84732"> </a>The <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b> routine calls <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>, which initializes PPP with the configuration options that were specified at compile-time (see <a href="c-dll4.html#84566"><i class="title">Selecting PPP Options By Configuring VxWorks</i></a>). The <b class="routine"><i class="routine">pppInit</i></b><b>( )</b> routine can be called multiple times to initialize multiple channels.<sup><a href="#foot"><b class="FootnoteMarker">2</b></a></sup> The connection timeout is specified by <b class="symbol_UC">PPP_CONNECT_DELAY</b>. The return value of this routine indicates whether the link has been successfully established--if the return value is <b class="symbol_lc">OK</b>, the network connection should be fully operational.</p><dd><p class="Body"><a name="84741"> </a>The <b class="routine"><i class="routine">pppInit</i></b><b>( )</b> routine is the standard entry point for initializing a PPP link. All available PPP options can be set using parameters specified for this routine (see <a href="c-dll4.html#84650"><i class="title">Selecting PPP Options Using an Options Structure</i></a>). Unlike <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b>, the return value of <b class="routine"><i class="routine">pppInit</i></b><b>( )</b> does not indicate the status of the PPP link; it merely reports whether the link could be initialized. To check whether the link is actually established, call <b class="routine"><i class="routine">pppInfoGet</i></b><b>( )</b> and make sure that the state of IPCP is <b class="symbol_lc">OPENED</b>. The following code fragment demonstrates use of this mechanism for PPP unit 2:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="94244">PPP_INFO pppInfo; if ((pppInfoGet (2, &pppInfo) == OK) && (pppInfo.ipcp_fsm.state == OPENED)) return (OK); /* link established */ else return (ERROR); /* link down */</a></b></pre></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84754">Deleting a PPP Link</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84756"> </a>There are two ways to delete a PPP link:</p></dl><dl class="margin"><ul class="BulletSingle" type="disc"><li><a name="84757"> </a>When a terminate request packet is received from the peer.</li></ul><ul class="BulletSingle" type="disc"><li><a name="84759"> </a>By calling <b class="routine"><i class="routine">pppDelete</i></b><b>( )</b> to terminate the link. </li></ul></dl><dl class="margin"><dd><p class="Body"><a name="84760"> </a>Merely deleting the VxWorks tasks that control PPP or rebooting the target severs the link only at the TCP/IP stack, but does not delete the link on the remote peer end.</p><dd><p class="Body"><a name="84761"> </a>The return value of <b class="routine"><i class="routine">pppDelete</i></b><b>( )</b> does not indicate the status of the PPP link. To check whether the link is actually terminated, call <b class="routine"><i class="routine">pppInfoGet</i></b><b>( )</b> and make sure the return value is <b class="symbol_UC">ERROR</b>. The following code fragment demonstrates the usage of this mechanism for PPP unit 4:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84762">PPP_INFO pppInfo; if (pppInfoGet (4, &pppInfo) == ERROR) return (OK); /* link terminated */ else return (ERROR); /* link still up */</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84769">PPP Options</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84774"> </a><a href="c-dll4.html#96246">Table 3-3</a> lists all the configuration options supported by PPP. Each option is shown in its three forms, corresponding to the configuration methods explained in the following sections:</p><dl class="margin"><dd><div class="Indent"><a name="84775"> </a>Column 1: <a href="c-dll4.html#84566"><i class="title">Selecting PPP Options By Configuring VxWorks</i></a></div><br><dd><div class="Indent"><a name="84780"> </a>Column 2: <a href="c-dll4.html#84650"><i class="title">Selecting PPP Options Using an Options Structure</i></a></div><br><dd><div class="Indent"><a name="84785"> </a>Column 3: <a href="c-dll4.html#93054"><i class="title">Setting PPP Options Using an Options File</i></a>. </div><br></dl><dd><p class="Body"><a name="84791"> </a>A brief description of each option follows the three formats. Configuration options specified in the options file <b class="symbol_UC">PPP_OPTIONS_FILE</b> take precedence over any previously set in <b class="file">config.h</b> or set by passing the structure <b class="symbol_UC">PPP_OPTIONS</b> to <b class="routine"><i class="routine">pppInit</i></b><b>( )</b>. For example:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="94646"> </a>If VxWorks is configured with the use of PAP negated, a subsequent setting of <b class="symbol_lc">require_pap</b> in <b class="symbol_UC">PPP_OPTIONS_FILE</b> overrides the earlier setting enabling PAP authentication. The relevant configuration macro is <b class="symbol_UC">PPP_OPT_NO_PAP</b>.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="94650"> </a>If <b class="symbol_lc">char * netmask</b> has been passed in the options structure <b class="symbol_UC">PPP_OPTIONS</b> to <b class="routine"><i class="routine">pppInit</i></b><b>( )</b> with a value of <b class="symbol_UC">FFFF0000</b>, and <b class="symbol_lc">netmask </b><b class="symbol_UC">FFFFFF00</b><b class="symbol_lc"> </b>is passed in <b class="symbol_UC">PPP_OPTIONS_FILE</b> to <b class="routine"><i class="routine">usrPPPInit</i></b><b>( )</b>, the network mask value is set to <b class="symbol_UC">FFFFFF00</b>. <p class="table"><h4 class="EntityTitle"><a name="96246"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 3-3: PPP Configuration Options </font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="3"><div class="CellHeading"><b><a name="96254"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Options</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="96260"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="96262"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Set in <b class="file">config.h </b></font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="96264"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Set using options structure</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="96266"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Set using options file</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><a name="96268"><font color="red"><blink></blink></font></a></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="96730"> </a><b class="symbol_UC">PPP_OPT_DEBUG</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="96732"> </a><b class="symbol_UC">OPT_DEBUG</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="96734"> </a><b class="symbol_lc">debug</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="96736"> </a>Enable PPP daemon debug mode. </div></td><td width="10"> </td></tr> <tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="96738"> </a><b class="symbol_UC">PPP_OPT_DEFAULT_ROUTE</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="96740"> </a><b class="symbol_UC">OPT_DEFAULT_ROUTE</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="96742"> </a><b class="symbol_lc">default_route</b></div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -