⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-netconfig2.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<dd><p class="Body"><a name="88244"> </a>The <b class="symbol_lc">cmd</b> parameters of both storage routines expect one of the following values:<sup><a href="#foot"><b class="FootnoteMarker">2</b></a></sup> </p></dl><dl class="margin"><dd><div class="Item"><a name="88245"> </a><b class="symbol_UC">DHCPS_STORAGE_START </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="88246"> </a>Tells your storage routine to perform any necessary initialization. Your storage routine should "reset" and thus return or  replace any previously stored data. </div><br></dl></dl><dd><div class="Item"><a name="88247"> </a><b class="symbol_UC">DHCPS_STORAGE_STOP</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="88248"> </a>Tells your storage routine to perform any necessary cleanup. After a stop, the storage routine should not perform any reads or writes until after the next start. </div><br></dl></dl><dd><div class="Item"><a name="88249"> </a><b class="symbol_UC">DHCPS_STORAGE_WRITE </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="88250"> </a>Tells the routine to store network configurations. Each write must store the data to some form of permanent storage. </div><br><dd><div class="Indent2"><a name="88251"> </a>The write functionality of your lease storage routine is critical. It is required to preserve the integrity of the protocol and prevent assignment of IP addresses to multiple clients. If the server is unable to store and retrieve the active network configurations, the results are unpredictable. The write functionality of the lease storage routine must accept a sequence of bytes of the indicated length. </div><br><dd><div class="Indent2"><a name="88252"> </a>The write functionality of the address storage routine must accept NULL-terminated strings containing the entry name, starting and ending addresses, and additional parameters. </div><br><dd><div class="Indent2"><a name="88253"> </a>If a write completes successfully, the routine must return OK.</div><br></dl></dl><dd><div class="Item"><a name="88254"> </a><b class="symbol_UC">DHCPS_STORAGE_READ </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="88255"> </a>Tells your storage routine to retrieve network configurations. Each read must copy the data (stored by earlier writes) into the buffers provided. The returned information must be of the same format provided to the write operation. </div><br><dd><div class="Indent2"><a name="88256"> </a>If a read completes successfully, your routine must return OK. If earlier reads have retrieved all available data, or no data is available, your routine must return  ERROR. The server calls your routine with read requests until ERROR is returned. </div><br></dl></dl><dd><div class="Item"><a name="88257"> </a><b class="symbol_UC">DHCPS_STORAGE_CLEAR</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="88258"> </a>Used only in calls to your lease storage routine. This value tells your routine that any data currently stored is no longer needed. Following this operation, reads should return error until after the next write.</div><br></dl></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="88260">Configuring the Unsupported DHCP Server</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88262"> </a>The unsupported DHCP server is a port of a public domain server available from the WIDE project. This port modifies the original code so that it supports Solaris as well as SunOS. As a convenience, WRS provides the code for the unsupported sever in <b class="file">target/unsupported/dhcp-1.3beta</b>. Unlike the supported VxWorks DHCP server, the unsupported server uses files to store the databases that track the IP addresses and the other configuration parameters that it distributes. </p><dd><p class="Body"><a name="88263"> </a>You can specify the names of these files in the <b class="command">dhcps</b> command that you use to start the DHCP server. If you do not specify the configuration files by name, the server uses the following defaults: <b class="file">/etc/dhcpdb.pool</b>, and <b class="file">/etc/dhcpdb.bind</b> (or <b class="file">/var/db/dhcpdb.bind</b> for BSD/OS). If the server supports a relay agent, it also maintains an extra database with the default name of <b class="file">/etc/dhcpdb.relay</b>. The server also creates other files as needed in the <b class="file">/etc </b>directory, but you do not need to edit these files to configure the server. </p><dd><p class="Body"><a name="88264"> </a>For the specifics of how you should edit these files, see the DHCPS(5), DHCPDB.POOL(5), and DHCPDB.RELAY(5) man pages included with the source code for the unsupported DHCP server.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="88265">5.2.4  &nbsp;&nbsp;Configuring the Supported DHCP Relay Agent </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88267"> </a>The relay agent uses some of the same configuration constants as the DHCP server:</p></dl><dl class="margin"><dd><div class="Item"><a name="88271"> </a>DHCP Server/Relay Agent Network Radius<b class="symbol_UC">  </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="91068"> </a>Default: 4. Hops before discard, up to 16. (Configuration constant: <b class="symbol_UC">DHCP_MAX_HOPS</b>)</div><br></dl></dl><dd><div class="Item"><a name="88274"> </a>DHCP Server/Relay Agent Host Port<b class="symbol_UC">  </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="91070"> </a>Default: 67. Port monitored by DHCP servers. (Configuration constant: <b class="symbol_UC">DHCPS_SPORT</b>)</div><br></dl></dl><dd><div class="Item"><a name="88277"> </a>DHCP Server/Relay Agent Target Port<b class="symbol_UC">  </b></div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="91072"> </a>Default: 68. Port monitored by DHCP clients. (Configuration constant: <b class="symbol_UC">DHCPS_CPORT</b>)</div><br></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="88280"> </a>If DHCP relay is configured into VxWorks (The relevant configuration macro is  <b class="symbol_UC">INCLUDE_DHCPR</b>), the build generates a VxWorks image that includes the DHCP relay agent. The relay agent reads the data structure contained in <b class="file">usrNetwork.c</b> to obtain the IP addresses of target DHCP servers or other relay agents. That data structure, <b>dhcpsRelayTbl</b>, has the following format: </p><dl class="margin"><dd><pre class="Code2"><b><a name="94335">DHCPS_RELAY_DESC dhcpsRelayTbl [] =     {     /* IP address of agent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subnet number        -------------------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;------------ &nbsp;    */     /* {"90.11.42.254",         "90.11.42.0"} */     };</a></b></pre></dl><dd><p class="Body"><a name="94336"> </a>Each entry in the table must specify a valid IP address for a DHCP server on a different subnet than the relay agent. The relay agent transmits a copy of all DHCP messages sent by clients to each of the specified addresses. The agent does <i class="emphasis">not</i> set the IP routing tables so that the specified target addresses are reachable.</p><dd><p class="Body"><a name="88291"> </a>The relay agent forwards DHCP client messages through only a limited number of targets: the DHCP Server/Relay Agent Network Radius. When the value specified in the VxWorks configuration is exceeded, the message is silently discarded. This value is only increased when the message is forwarded by a DHCP agent. It is completely independent of the similar value used by IP routers. RFC 1542 specifies the maximum value of 16 for this constant. The default hops value is four.</p><dd><p class="Body"><a name="88293"> </a>Beyond providing the list of target addresses, and optionally changing the maximum number of hops permitted, no further action is necessary. The DHCP relay agent executes automatically whenever it is included in the VxWorks image.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="88297">5.2.5  &nbsp;&nbsp;DHCP Within an Application</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88299"> </a>The target-resident DHCP client can retrieve multiple sets of configuration parameters. These retrieval requests can execute either synchronously or asynchronously. In addition, the retrieved network configuration information can be applied directly to the underlying network interface or used for some other purpose. The following example demonstrates the asynchronous execution of a DHCP request for a lease with a 30 minute duration in which the retrieved configuration parameters are applied to the network interface used to contact the DHCP server.<sup><a href="#foot"><b class="FootnoteMarker">3</b></a></sup></p></dl><dl class="margin"><dd><pre class="Code"><b><a name="88303">    pIf = ifunit ("net0");     /* Access network device. */      /* Initialize lease variables for automatic configuration. */      pLeaseCookie = dhcpcInit (pIf, TRUE);     if (pLeaseCookie == NULL)         return (ERROR);      /* Set any lease options here. */      dhcpcOptionSet (pLeaseCookie, _DHCP_LEASE_TIME_TAG, 1800, 0, NULL);      result = dhcpcBind (pLeaseCookie, FALSE);  /* Asynchronous execution. */     if (result != OK)         return (ERROR);</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="88320"> </a>In the code above, the <b class="routine"><i class="routine">dhcpcInit</i></b><b>(&nbsp;)</b> call used a value of TRUE for the <i class="textVariable">autoconfig</i> parameter. This automatically includes a request for a subnet mask and broadcast address in the cookie (<b class="symbol_lc">pLeaseCookie</b>). To request additional options for this lease (such as a lease duration of 30 minutes) the code makes a call to <b class="routine"><i class="routine">dhcpcOptionSet</i></b><b>(&nbsp;)</b>. Because the DHCP protocol requires that all requested parameters be specified before a lease is established, the <b class="routine"><i class="routine">dhcpcOptionSet</i></b><b>(&nbsp;)</b> call must precede the asynchronous <b class="routine"><i class="routine">dhcpcBind</i></b><b>(&nbsp;)</b>call that establishes the lease. </p><dd><p class="Body"><a name="88322"> </a>Although it is omitted from the example, you can use a <b class="routine"><i class="routine">dhcpcLeaseHookAdd</i></b><b>(&nbsp;)</b>call to associate a lease event hook routine with this lease. That way, you can note the <b class="symbol_UC">DHCPC_LEASE_NEW</b> event that occurs when the asynchronous <b class="routine"><i class="routine">dhcpcBind</i></b><b>(&nbsp;)</b> completes its negotiations with the DHCP server. </p><dd><p class="Body"><a name="88323"> </a>To query the local DHCP client for a parameter value from the lease information it has retrieved, call <b class="routine"><i class="routine">dhcpcOptionGet</i></b><b>(&nbsp;)</b>. This routine checks whether the lease associated with a particular lease cookie is valid and whether the requested parameter was provided by the server. If so, <b class="routine"><i class="routine">dhcpcOptionGet</i></b><b>(&nbsp;)</b>copies the parameter value into a buffer. Otherwise, it returns ERROR. A call to <b class="routine"><i class="routine">dhcpcOptionGet</i></b><b>(&nbsp;)</b> generates no network traffic; it queries the local DHCP client for the information it needs. The following sample demonstrates the use of this routine:</p><dl class="margin"><dd><pre class="Code2"><b><a name="93912">inet_addr webServer; STATUS result; ... result = dhcpcOptionGet (pLeaseCookie, _DHCP_DFLT_WWW_SERVER_TAG, 4,                         &amp;webServer); if (result == OK) &nbsp;&nbsp;&nbsp;&nbsp;printf("Primary web server: %s", inet_ntoa (webServer));  ...</a></b></pre></dl></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="93917"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>To check on configuration parameters associated with a lease established at boot time, use the <b class="library">pDhcpcBootCookie </b>global variable as the lease cookie in a call to <b class="routine"><i class="routine">dhcpcOptionGet</i></b><b>(&nbsp;)</b>.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="93923"> </a>In addition to <b class="routine"><i class="routine">dhcpcOptionGet</i></b><b>(&nbsp;)</b>, you can use <b class="routine"><i class="routine">dhcpcParamsGet</i></b><b>(&nbsp;)</b> to retrieve multiple lease parameter values simultaneously. The DHCP client library also provides other routines that you can use to get the values of particular parameters (such as the lease timers) without supplying their option tags. </p><dd><p class="Body"><a name="88344"> </a>For more information on DHCP client features, see the <b class="library">dhcpcLib</b> manual pages.</p></dl></dl><a name="foot"><hr></a><p class="FootnoteNumberMarker">1:&nbsp;<span class="Footnote"><a name="88080"> </a>In addition to the supported target-resident server, VxWorks also includes source for an unsupported UNIX-compatible DHCP server. See <b class="file">target/unsupported/dhcp-1.3beta</b>. </span><p class="FootnoteNumberMarker">2:&nbsp;<span class="Footnote"><a name="88243"> </a>These symbolic constants are defined in <b class="file">dhcpsLib.h</b>. </span><p class="FootnoteNumberMarker">3:&nbsp;<span class="Footnote"><a name="88302"> </a>The limit on the number of concurrent leases is the "DHCP Client Maximum Leases" value set during configuration (configuration constant: <b class="symbol_UC">DHCPC_MAX_LEASES</b>). When setting this value, remember to count the lease (if any) that the client retrieved at boot time. </span><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-netconfig.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-netconfig.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-netconfig1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-netconfig3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -