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

📄 dns_8c-source.html

📁 Freescale mcu OpenTCP-1.0.4.doc.html.zip 文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
00378                                                 }00379 00380                                                 <span class="keywordflow">return</span> 0;00381                                         }<span class="keywordflow">else</span>{00382                                                 <span class="comment">/* nope, skip other bytes */</span>00383                                                 <span class="keywordflow">while</span>(tmp_int--)00384                                                         <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00385                                         }00386                                 }<span class="keywordflow">else</span>{00387 00388                                         DEBUGOUT(<span class="stringliteral">"DNS: RR.CLASS not INET. Skipping!\r\n"</span>);00389 00390                                         <span class="comment">/* skip TTL and read RDLENGTH*/</span>00391                                         <span class="keywordflow">for</span>(tmp_byte=0;tmp_byte&lt;6;tmp_byte++){00392                                                 tmp_int=(tmp_int&lt;&lt;8)+<a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00393                                         }00394 00395                                         <span class="comment">/* skip RDATA */</span>00396                                         <span class="keywordflow">while</span>(tmp_int--)00397                                                 <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00398                                 }00399                                 <span class="comment">/* decrement counters */</span>00400                                 <span class="keywordflow">if</span>(dns_ancount)00401                                         dns_ancount--;00402                                 <span class="keywordflow">else</span>00403                                         <span class="keywordflow">if</span>(dns_nscount)00404                                                 dns_nscount--;00405 00406                         }00407                         <span class="keywordflow">break</span>;00408 00409                 <span class="keywordflow">default</span>:00410                         DEBUGOUT(<span class="stringliteral">"DNS: unknown UDP event :-("</span>);00411                         <span class="keywordflow">break</span>;00412         }00413         <span class="keywordflow">return</span> 0;00414 }00415 <a name="l00445"></a><a class="code" href="dns_8c.html#a14">00445</a> UINT8 <a class="code" href="dns_8c.html#a14">get_host_by_name</a>(UINT8 *host_name_ptr, <span class="keywordtype">void</span> (*listener)(UINT8 , UINT32 )){00446 00447         UINT8 *buf_ptr;00448         INT8 i;00449         UINT16 total;00450 00451         <span class="keywordflow">switch</span>(dns_state){00452 00453                 <span class="keywordflow">case</span> DNS_STATE_READY:00454                         <a class="code" href="dns_8c.html#a3">dns_state</a>=DNS_STATE_BUSY;00455                         <a class="code" href="dns_8c.html#a8">dns_hostptr</a>=host_name_ptr;00456                         dns_event_listener=listener;00457                         <a class="code" href="dns_8c.html#a7">dns_tmp_ip</a>=<a class="code" href="dns_8h.html#a1">DNS_SERVER_IP</a>;00458                         <a class="code" href="dns_8c.html#a6">dns_retries</a>=<a class="code" href="dns_8h.html#a3">DNS_NUM_RETRIES</a>;00459                         <a class="code" href="timers_8c.html#a6">init_timer</a>(<a class="code" href="dns_8c.html#a5">dns_timer</a>,<a class="code" href="dns_8h.html#a2">DNS_RESEND_PERIOD</a>*<a class="code" href="timers_8h.html#a1">TIMERTIC</a>);00460                         <span class="keywordflow">break</span>;00461 00462                 <span class="keywordflow">case</span> DNS_STATE_BUSY:00463                         DEBUGOUT(<span class="stringliteral">"DNS: Error, trying to invoke two DNS requests at the same time!\r\n"</span>);00464                         <span class="keywordflow">return</span>  <a class="code" href="dns_8h.html#a13">DNS_ERROR_BUSY</a>;00465 00466 00467                 <span class="keywordflow">case</span> DNS_STATE_RESEND:00468                         <span class="keywordflow">if</span>(host_name_ptr!=<a class="code" href="dns_8c.html#a8">dns_hostptr</a>){00469                                 DEBUGOUT(<span class="stringliteral">"DNS: Ptrs different. Can't do that! \r\n"</span>);00470                                 <span class="keywordflow">return</span> <a class="code" href="dns_8h.html#a13">DNS_ERROR_BUSY</a>;00471                         }00472                         <span class="keywordflow">break</span>;00473 00474                 <span class="keywordflow">default</span>:00475                         DEBUGOUT(<span class="stringliteral">"DNS: What am I doing in this state?\r\n"</span>);00476                         <a class="code" href="system_8h.html#a6">RESET_SYSTEM</a>();00477         }00478 00479 00480         <span class="comment">/* OK, create message in the Netbuf transmit buffer */</span>00481 00482         buf_ptr=net_buf+<a class="code" href="tcp__ip_8h.html#a62">UDP_APP_OFFSET</a>;00483 00484         <span class="comment">/* first the header */</span>00485         *((UINT16 *)buf_ptr)=0xAAAA; <span class="comment">/* id, fixed for now*/</span>00486         buf_ptr+=2;00487 00488         *buf_ptr++=0x01;00489         *buf_ptr++=0x00;00490 00491         <span class="comment">/*question count*/</span>00492         *buf_ptr++=0x00;00493         *buf_ptr++=0x01;00494 00495         <span class="comment">/* others are zero */</span>00496         <span class="keywordflow">for</span>(i=0;i&lt;6;i++)00497                 *buf_ptr++=0x00;00498 00499         <span class="comment">/* ok, create the question section */</span>00500         total=0;00501 00502         <span class="keywordflow">while</span>((*host_name_ptr)!=<span class="charliteral">'\0'</span>){00503 00504                 <span class="comment">/* we are still not at the end. Reserve space for count */</span>00505                 buf_ptr++;00506                 i=0;00507 00508                 <span class="keywordflow">while</span>(((*host_name_ptr)!=<span class="charliteral">'.'</span>)&amp;&amp;((*host_name_ptr)!=<span class="charliteral">'\0'</span>)){00509                         i++;00510                         *buf_ptr++=*host_name_ptr++;00511                         <span class="keywordflow">if</span>(buf_ptr==(net_buf+<a class="code" href="group__opentcp__config.html#a4">NETWORK_TX_BUFFER_SIZE</a>)){00512                                 DEBUGOUT(<span class="stringliteral">"DNS: Buffer overflow!!!\r\n"</span>);00513                                 <span class="keywordflow">return</span>(DNS_ERROR_OVERFLOW);00514                         }00515                 }00516 00517                 <span class="comment">/* label shorter than 63 bytes or less? */</span>00518                 <span class="keywordflow">if</span>((i&lt;=0)||(i&gt;=64)){00519                         DEBUGOUT(<span class="stringliteral">"DNS: Label size wrong! Aborting....\r\n"</span>);00520                         <span class="keywordflow">return</span>(DNS_ERROR_LABEL);00521                 }00522 00523                 <span class="comment">/* it seems ok for now. Increase total name length*/</span>00524                 total+=i;00525 00526                 <span class="keywordflow">if</span>(total&gt;=264){00527                         DEBUGOUT(<span class="stringliteral">"DNS: Name size wrong! Aborting....\r\n"</span>);00528                         <span class="keywordflow">return</span>(DNS_ERROR_NAME);00529                 }00530 00531                 *(buf_ptr-i-1)=i;       <span class="comment">/* store label length */</span>00532 00533                 <span class="comment">/* ok, where are we ? */</span>00534                 <span class="keywordflow">if</span>((*host_name_ptr)==<span class="charliteral">'.'</span>){00535                         <span class="comment">/* still not at the end, skip dot */</span>00536                         host_name_ptr++;00537                 }<span class="keywordflow">else</span>00538                         <span class="keywordflow">if</span>((*host_name_ptr)==<span class="charliteral">'\0'</span>){00539                                 <span class="comment">/* OHO, finished,</span>00540 <span class="comment">                                        add ZERO,QTYPE and QCLASS */</span>00541                                 *buf_ptr++=0x00;00542                                 *buf_ptr++=0x00;00543                                 *buf_ptr++=0x01;00544                                 *buf_ptr++=0x00;00545                                 *buf_ptr++=0x01;00546                                 kick_WD();00547                                 <span class="comment">/* ok, now send the request */</span>00548                                 <span class="keywordflow">return</span> <a class="code" href="udp_8c.html#a7">udp_send</a>(<a class="code" href="dns_8c.html#a4">dns_socket</a>,<a class="code" href="dns_8c.html#a7">dns_tmp_ip</a>,<a class="code" href="dns_8h.html#a0">DNS_UDP_PORT</a>,net_buf+<a class="code" href="tcp__ip_8h.html#a62">UDP_APP_OFFSET</a>,<a class="code" href="group__opentcp__config.html#a4">NETWORK_TX_BUFFER_SIZE</a>-<a class="code" href="tcp__ip_8h.html#a62">UDP_APP_OFFSET</a>,buf_ptr-(net_buf+<a class="code" href="tcp__ip_8h.html#a62">UDP_APP_OFFSET</a>));00549                         }00550         }00551 }00552 </pre></div><hr><address style="align: right;"><small>Generated on Sun Aug 3 20:32:59 2003 for OpenTCP by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

⌨️ 快捷键说明

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