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

📄 a00202.html

📁 最新的免费嵌入式系统TCP/IP协议栈!
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00273"></a>00273 <span class="comment"> * this:</span><a name="l00274"></a>00274 <span class="comment"> \code</span><a name="l00275"></a>00275 <span class="comment">  for(i = 0; i &lt; UIP_CONNS; ++i) {</span><a name="l00276"></a>00276 <span class="comment">    uip_periodic(i);</span><a name="l00277"></a>00277 <span class="comment">    if(uip_len &gt; 0) {</span><a name="l00278"></a>00278 <span class="comment">      devicedriver_send();</span><a name="l00279"></a>00279 <span class="comment">    }</span><a name="l00280"></a>00280 <span class="comment">  }</span><a name="l00281"></a>00281 <span class="comment"> \endcode</span><a name="l00282"></a>00282 <span class="comment"> *</span><a name="l00283"></a>00283 <span class="comment"> * \note If you are writing a uIP device driver that needs ARP</span><a name="l00284"></a>00284 <span class="comment"> * (Address Resolution Protocol), e.g., when running uIP over</span><a name="l00285"></a>00285 <span class="comment"> * Ethernet, you will need to call the uip_arp_out() function before</span><a name="l00286"></a>00286 <span class="comment"> * calling the device driver:</span><a name="l00287"></a>00287 <span class="comment"> \code</span><a name="l00288"></a>00288 <span class="comment">  for(i = 0; i &lt; UIP_CONNS; ++i) {</span><a name="l00289"></a>00289 <span class="comment">    uip_periodic(i);</span><a name="l00290"></a>00290 <span class="comment">    if(uip_len &gt; 0) {</span><a name="l00291"></a>00291 <span class="comment">      uip_arp_out();</span><a name="l00292"></a>00292 <span class="comment">      ethernet_devicedriver_send();</span><a name="l00293"></a>00293 <span class="comment">    }</span><a name="l00294"></a>00294 <span class="comment">  }</span><a name="l00295"></a>00295 <span class="comment"> \endcode</span><a name="l00296"></a>00296 <span class="comment"> *</span><a name="l00297"></a>00297 <span class="comment"> * \param conn The number of the connection which is to be periodically polled.</span><a name="l00298"></a>00298 <span class="comment"> *</span><a name="l00299"></a>00299 <span class="comment"> * \hideinitializer</span><a name="l00300"></a>00300 <span class="comment"> */</span><a name="l00301"></a><a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">00301</a> <span class="preprocessor">#define uip_periodic(conn) do { uip_conn = &amp;uip_conns[conn]; \</span><a name="l00302"></a>00302 <span class="preprocessor">                                uip_process(UIP_TIMER); } while (0)</span><a name="l00303"></a>00303 <span class="preprocessor"></span><span class="comment"></span><a name="l00304"></a>00304 <span class="comment">/**</span><a name="l00305"></a>00305 <span class="comment"> *</span><a name="l00306"></a>00306 <span class="comment"> *</span><a name="l00307"></a>00307 <span class="comment"> */</span><a name="l00308"></a><a class="code" href="a00146.html#gfd5ebb56a1bd1da9878aa886a2075e80">00308</a> <span class="preprocessor">#define uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED)</span><a name="l00309"></a>00309 <span class="preprocessor"></span><span class="comment"></span><a name="l00310"></a>00310 <span class="comment">/**</span><a name="l00311"></a>00311 <span class="comment"> * Perform periodic processing for a connection identified by a pointer</span><a name="l00312"></a>00312 <span class="comment"> * to its structure.</span><a name="l00313"></a>00313 <span class="comment"> *</span><a name="l00314"></a>00314 <span class="comment"> * Same as uip_periodic() but takes a pointer to the actual uip_conn</span><a name="l00315"></a>00315 <span class="comment"> * struct instead of an integer as its argument. This function can be</span><a name="l00316"></a>00316 <span class="comment"> * used to force periodic processing of a specific connection.</span><a name="l00317"></a>00317 <span class="comment"> *</span><a name="l00318"></a>00318 <span class="comment"> * \param conn A pointer to the uip_conn struct for the connection to</span><a name="l00319"></a>00319 <span class="comment"> * be processed.</span><a name="l00320"></a>00320 <span class="comment"> *</span><a name="l00321"></a>00321 <span class="comment"> * \hideinitializer</span><a name="l00322"></a>00322 <span class="comment"> */</span><a name="l00323"></a><a class="code" href="a00146.html#gbaf0bb2b6a4424b4eb69e45e457c2583">00323</a> <span class="preprocessor">#define uip_periodic_conn(conn) do { uip_conn = conn; \</span><a name="l00324"></a>00324 <span class="preprocessor">                                     uip_process(UIP_TIMER); } while (0)</span><a name="l00325"></a>00325 <span class="preprocessor"></span><span class="comment"></span><a name="l00326"></a>00326 <span class="comment">/**</span><a name="l00327"></a>00327 <span class="comment"> * Reuqest that a particular connection should be polled.</span><a name="l00328"></a>00328 <span class="comment"> *</span><a name="l00329"></a>00329 <span class="comment"> * Similar to uip_periodic_conn() but does not perform any timer</span><a name="l00330"></a>00330 <span class="comment"> * processing. The application is polled for new data.</span><a name="l00331"></a>00331 <span class="comment"> *</span><a name="l00332"></a>00332 <span class="comment"> * \param conn A pointer to the uip_conn struct for the connection to</span><a name="l00333"></a>00333 <span class="comment"> * be processed.</span><a name="l00334"></a>00334 <span class="comment"> *</span><a name="l00335"></a>00335 <span class="comment"> * \hideinitializer</span><a name="l00336"></a>00336 <span class="comment"> */</span><a name="l00337"></a><a class="code" href="a00146.html#gf20aaf4292cb0d2a1b10bc0a568b51fa">00337</a> <span class="preprocessor">#define uip_poll_conn(conn) do { uip_conn = conn; \</span><a name="l00338"></a>00338 <span class="preprocessor">                                 uip_process(UIP_POLL_REQUEST); } while (0)</span><a name="l00339"></a>00339 <span class="preprocessor"></span><a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="preprocessor">#if UIP_UDP</span><a name="l00342"></a>00342 <span class="preprocessor"></span><span class="comment">/**</span><a name="l00343"></a>00343 <span class="comment"> * Periodic processing for a UDP connection identified by its number.</span><a name="l00344"></a>00344 <span class="comment"> *</span><a name="l00345"></a>00345 <span class="comment"> * This function is essentially the same as uip_periodic(), but for</span><a name="l00346"></a>00346 <span class="comment"> * UDP connections. It is called in a similar fashion as the</span><a name="l00347"></a>00347 <span class="comment"> * uip_periodic() function:</span><a name="l00348"></a>00348 <span class="comment"> \code</span><a name="l00349"></a>00349 <span class="comment">  for(i = 0; i &lt; UIP_UDP_CONNS; i++) {</span><a name="l00350"></a>00350 <span class="comment">    uip_udp_periodic(i);</span><a name="l00351"></a>00351 <span class="comment">    if(uip_len &gt; 0) {</span><a name="l00352"></a>00352 <span class="comment">      devicedriver_send();</span><a name="l00353"></a>00353 <span class="comment">    }</span><a name="l00354"></a>00354 <span class="comment">  }</span><a name="l00355"></a>00355 <span class="comment"> \endcode</span><a name="l00356"></a>00356 <span class="comment"> *</span><a name="l00357"></a>00357 <span class="comment"> * \note As for the uip_periodic() function, special care has to be</span><a name="l00358"></a>00358 <span class="comment"> * taken when using uIP together with ARP and Ethernet:</span><a name="l00359"></a>00359 <span class="comment"> \code</span><a name="l00360"></a>00360 <span class="comment">  for(i = 0; i &lt; UIP_UDP_CONNS; i++) {</span><a name="l00361"></a>00361 <span class="comment">    uip_udp_periodic(i);</span><a name="l00362"></a>00362 <span class="comment">    if(uip_len &gt; 0) {</span><a name="l00363"></a>00363 <span class="comment">      uip_arp_out();</span><a name="l00364"></a>00364 <span class="comment">      ethernet_devicedriver_send();</span><a name="l00365"></a>00365 <span class="comment">    }</span><a name="l00366"></a>00366 <span class="comment">  }</span><a name="l00367"></a>00367 <span class="comment"> \endcode</span><a name="l00368"></a>00368 <span class="comment"> *</span><a name="l00369"></a>00369 <span class="comment"> * \param conn The number of the UDP connection to be processed.</span><a name="l00370"></a>00370 <span class="comment"> *</span><a name="l00371"></a>00371 <span class="comment"> * \hideinitializer</span><a name="l00372"></a>00372 <span class="comment"> */</span><a name="l00373"></a><a class="code" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">00373</a> <span class="preprocessor">#define uip_udp_periodic(conn) do { uip_udp_conn = &amp;uip_udp_conns[conn]; \</span><a name="l00374"></a>00374 <span class="preprocessor">                                uip_process(UIP_UDP_TIMER); } while (0)</span><a name="l00375"></a>00375 <span class="preprocessor"></span><span class="comment"></span><a name="l00376"></a>00376 <span class="comment">/**</span><a name="l00377"></a>00377 <span class="comment"> * Periodic processing for a UDP connection identified by a pointer to</span><a name="l00378"></a>00378 <span class="comment"> * its structure.</span><a name="l00379"></a>00379 <span class="comment"> *</span><a name="l00380"></a>00380 <span class="comment"> * Same as uip_udp_periodic() but takes a pointer to the actual</span><a name="l00381"></a>00381 <span class="comment"> * uip_conn struct instead of an integer as its argument. This</span><a name="l00382"></a>00382 <span class="comment"> * function can be used to force periodic processing of a specific</span><a name="l00383"></a>00383 <span class="comment"> * connection.</span><a name="l00384"></a>00384 <span class="comment"> *</span><a name="l00385"></a>00385 <span class="comment"> * \param conn A pointer to the uip_udp_conn struct for the connection</span><a name="l00386"></a>00386 <span class="comment"> * to be processed.</span><a name="l00387"></a>00387 <span class="comment"> *</span><a name="l00388"></a>00388 <span class="comment"> * \hideinitializer</span><a name="l00389"></a>00389 <span class="comment"> */</span><a name="l00390"></a><a class="code" href="a00146.html#gf5c2ad5acf3cc23b8262e9ba6a15136b">00390</a> <span class="preprocessor">#define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \</span><a name="l00391"></a>00391 <span class="preprocessor">                                         uip_process(UIP_UDP_TIMER); } while (0)</span><a name="l00392"></a>00392 <span class="preprocessor"></span><a name="l00393"></a>00393 <a name="l00394"></a>00394 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span><a name="l00395"></a>00395 <span class="comment"></span><a name="l00396"></a>00396 <span class="comment">/**</span><a name="l00397"></a>00397 <span class="comment"> * The uIP packet buffer.</span><a name="l00398"></a>00398 <span class="comment"> *</span><a name="l00399"></a>00399 <span class="comment"> * The uip_buf array is used to hold incoming and outgoing</span><a name="l00400"></a>00400 <span class="comment"> * packets. The device driver should place incoming data into this</span><a name="l00401"></a>00401 <span class="comment"> * buffer. When sending data, the device driver should read the link</span><a name="l00402"></a>00402 <span class="comment"> * level headers and the TCP/IP headers from this buffer. The size of</span><a name="l00403"></a>00403 <span class="comment"> * the link level headers is configured by the UIP_LLH_LEN define.</span><a name="l00404"></a>00404 <span class="comment"> *</span><a name="l00405"></a>00405 <span class="comment"> * \note The application data need not be placed in this buffer, so</span><a name="l00406"></a>00406 <span class="comment"> * the device driver must read it from the place pointed to by the</span><a name="l00407"></a>00407 <span class="comment"> * uip_appdata pointer as illustrated by the following example:</span><a name="l00408"></a>00408 <span class="comment"> \code</span><a name="l00409"></a>00409 <span class="comment"> void</span><a name="l00410"></a>00410 <span class="comment"> devicedriver_send(void)</span><a name="l00411"></a>00411 <span class="comment"> {</span><a name="l00412"></a>00412 <span class="comment">    hwsend(&amp;uip_buf[0], UIP_LLH_LEN);</span><a name="l00413"></a>00413 <span class="comment">    if(uip_len &lt;= UIP_LLH_LEN + UIP_TCPIP_HLEN) {</span><a name="l00414"></a>00414 <span class="comment">      hwsend(&amp;uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN);</span><a name="l00415"></a>00415 <span class="comment">    } else {</span><a name="l00416"></a>00416 <span class="comment">      hwsend(&amp;uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);</span><a name="l00417"></a>00417 <span class="comment">      hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);</span><a name="l00418"></a>00418 <span class="comment">    }</span>

⌨️ 快捷键说明

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