亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dns.c

?? 最新的lwip 1.3.0版本在ucos平臺上的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
/** * @file * DNS - host name to IP address resolver. * *//** * This file implements a DNS host name to IP address resolver. * Port to lwIP from uIP * by Jim Pettinato April 2007 * uIP version Copyright (c) 2002-2003, Adam Dunkels. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote *    products derived from this software without specific prior *    written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * DNS.C * * The lwIP DNS resolver functions are used to lookup a host name and * map it to a numerical IP address. It maintains a list of resolved * hostnames that can be queried with the dns_lookup() function. * New hostnames can be resolved using the dns_query() function. * * The lwIP version of the resolver also adds a non-blocking version of * gethostbyname() that will work with a raw API application. This function * checks for an IP address string first and converts it if it is valid. * gethostbyname() then does a dns_lookup() to see if the name is  * already in the table. If so, the IP is returned. If not, a query is  * issued and the function returns with a ERR_INPROGRESS status. The app * using the dns client must then go into a waiting state. * * Once a hostname has been resolved (or found to be non-existent), * the resolver code calls a specified callback function (which  * must be implemented by the module that uses the resolver). *//*----------------------------------------------------------------------------- * RFC 1035 - Domain names - implementation and specification * RFC 2181 - Clarifications to the DNS Specification *----------------------------------------------------------------------------*//** @todo: define good default values (rfc compliance) *//** @todo: improve answer parsing, more checkings... *//** @todo: check RFC1035 - 7.3. Processing responses *//*----------------------------------------------------------------------------- * Includes *----------------------------------------------------------------------------*/#include "lwip/opt.h"#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */#include "lwip/udp.h"#include "lwip/mem.h"#include "lwip/dns.h"#include <string.h>/** DNS server IP address */#ifndef DNS_SERVER_ADDRESS#define DNS_SERVER_ADDRESS        inet_addr("208.67.222.222") /* resolver1.opendns.com */#endif/** DNS server port address */#ifndef DNS_SERVER_PORT#define DNS_SERVER_PORT           53#endif/** DNS maximum number of retries when asking for a name, before "timeout". */#ifndef DNS_MAX_RETRIES#define DNS_MAX_RETRIES           4#endif/** DNS resource record max. TTL (one week as default) */#ifndef DNS_MAX_TTL#define DNS_MAX_TTL               604800#endif/* DNS protocol flags */#define DNS_FLAG1_RESPONSE        0x80#define DNS_FLAG1_OPCODE_STATUS   0x10#define DNS_FLAG1_OPCODE_INVERSE  0x08#define DNS_FLAG1_OPCODE_STANDARD 0x00#define DNS_FLAG1_AUTHORATIVE     0x04#define DNS_FLAG1_TRUNC           0x02#define DNS_FLAG1_RD              0x01#define DNS_FLAG2_RA              0x80#define DNS_FLAG2_ERR_MASK        0x0f#define DNS_FLAG2_ERR_NONE        0x00#define DNS_FLAG2_ERR_NAME        0x03/* DNS protocol states */#define DNS_STATE_UNUSED          0#define DNS_STATE_NEW             1#define DNS_STATE_ASKING          2#define DNS_STATE_DONE            3#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/bpstruct.h"#endifPACK_STRUCT_BEGIN/** DNS message header */struct dns_hdr {  u16_t id;  u8_t flags1;  u8_t flags2;  u16_t numquestions;  u16_t numanswers;  u16_t numauthrr;  u16_t numextrarr;} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/bpstruct.h"#endifPACK_STRUCT_BEGIN/** DNS query message structure */struct dns_query {  /* DNS query record starts with either a domain name or a pointer     to a name already present somewhere in the packet. */  u16_t type;  u16_t class;} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/bpstruct.h"#endifPACK_STRUCT_BEGIN/** DNS answer message structure */struct dns_answer {  /* DNS answer record starts with either a domain name or a pointer     to a name already present somewhere in the packet. */  u16_t type;  u16_t class;  u32_t ttl;  u16_t len;} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif/** DNS table entry */struct dns_table_entry {  u8_t  state;  u8_t  numdns;  u8_t  tmr;  u8_t  retries;  u8_t  seqno;  u8_t  err;  u32_t ttl;  char name[DNS_MAX_NAME_LENGTH];  struct ip_addr ipaddr;  /* pointer to callback on DNS query done */  dns_found_callback found;  void *arg;};/* forward declarations */static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);static void dns_check_entries(void);/*----------------------------------------------------------------------------- * Globales *----------------------------------------------------------------------------*//* DNS variables */static struct udp_pcb        *dns_pcb;static u8_t                   dns_seqno;static struct dns_table_entry dns_table[DNS_TABLE_SIZE];static struct ip_addr         dns_servers[DNS_MAX_SERVERS];#if (DNS_USES_STATIC_BUF == 1)static u8_t                   dns_payload[DNS_MSG_SIZE];#endif /* (DNS_USES_STATIC_BUF == 1) *//** * Initialize the resolver: set up the UDP pcb and configure the default server * (DNS_SERVER_ADDRESS). */voiddns_init(){  struct ip_addr dnsserver;    /* initialize default DNS server address */  dnsserver.addr = DNS_SERVER_ADDRESS;  LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n"));  /* if dns client not yet initialized... */  if (dns_pcb == NULL) {    dns_pcb = udp_new();    if (dns_pcb != NULL) {      /* initialize DNS table not needed (initialized to zero since it is a       * global variable) */      LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0",        DNS_STATE_UNUSED == 0);      /* initialize DNS client */      udp_bind(dns_pcb, IP_ADDR_ANY, 0);      udp_recv(dns_pcb, dns_recv, NULL);      /* initialize default DNS primary server */      dns_setserver(0, &dnsserver);    }  }}/** * Initialize one of the DNS servers. * * @param numdns the index of the DNS server to set must be < DNS_MAX_SERVERS * @param dnsserver IP address of the DNS server to set */voiddns_setserver(u8_t numdns, struct ip_addr *dnsserver){  if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) &&      (dnsserver != NULL) && (dnsserver->addr !=0 )) {    dns_servers[numdns] = (*dnsserver);  }}/** * Obtain one of the currently configured DNS server. * * @param numdns the index of the DNS server * @return IP address of the indexed DNS server or "ip_addr_any" if the DNS *         server has not been configured. */struct ip_addrdns_getserver(u8_t numdns){  if (numdns < DNS_MAX_SERVERS) {    return dns_servers[numdns];  } else {    return *IP_ADDR_ANY;  }}/** * The DNS resolver client timer - handle retries and timeouts and should * be called every DNS_TMR_INTERVAL milliseconds (every second by default). */voiddns_tmr(void){  if (dns_pcb != NULL) {    LWIP_DEBUGF(DNS_DEBUG, ("dns_tmr: dns_check_entries\n"));    dns_check_entries();  }}/** * Look up a hostname in the array of known hostnames. * * @note This function only looks in the internal array of known * hostnames, it does not send out a query for the hostname if none * was found. The function dns_enqueue() can be used to send a query * for a hostname. * * @param name the hostname to look up * @return the hostname's IP address, as u32_t (instead of struct ip_addr to *         better check for failure: != 0) or 0 if the hostname was not found *         in the cached dns_table. */static u32_tdns_lookup(const char *name){  u8_t i;  /* Walk through name list, return entry if found. If not, return NULL. */  for (i = 0; i < DNS_TABLE_SIZE; ++i) {    if ((dns_table[i].state == DNS_STATE_DONE) &&        (strcmp(name, dns_table[i].name) == 0)) {      LWIP_DEBUGF(DNS_DEBUG, ("dns_lookup: \"%s\": found = ", name));      ip_addr_debug_print(DNS_DEBUG, &(dns_table[i].ipaddr));      LWIP_DEBUGF(DNS_DEBUG, ("\n"));      return dns_table[i].ipaddr.addr;    }  }  return 0;}#if DNS_DOES_NAME_CHECK/** * Compare the "dotted" name "query" with the encoded name "response" * to make sure an answer from the DNS server matches the current dns_table * entry (otherwise, answers might arrive late for hostname not on the list * any more). * * @param query hostname (not encoded) from the dns_table * @param response encoded hostname in the DNS response * @return 0: names equal; 1: names differ */static u8_tdns_compare_name(unsigned char *query, unsigned char *response){  unsigned char n;  do {    n = *response++;    /** @see RFC 1035 - 4.1.4. Message compression */    if ((n & 0xc0) == 0xc0) {      /* Compressed name */      break;    } else {      /* Not compressed name */      while (n > 0) {        if ((*query) != (*response)) {          return 1;        }        ++response;        ++query;        --n;      };      ++query;    }  } while (*response != 0);  return 0;}#endif /* DNS_DOES_NAME_CHECK *//** * Walk through a compact encoded DNS name and return the end of the name. * * @param query encoded DNS name in the DNS server response * @return end of the name */static unsigned char *dns_parse_name(unsigned char *query){  unsigned char n;  do {    n = *query++;    /** @see RFC 1035 - 4.1.4. Message compression */    if ((n & 0xc0) == 0xc0) {      /* Compressed name */      break;    } else {      /* Not compressed name */      while (n > 0) {        ++query;        --n;      };    }  } while (*query != 0);  return query + 1;}/** * Send a DNS query packet. * * @param numdns index of the DNS server in the dns_servers table * @param name hostname to query * @param id index of the hostname in dns_table, used as transaction ID in the *        DNS query packet * @return ERR_OK if packet is sent; an err_t indicating the problem otherwise */static err_tdns_send(u8_t numdns, const char* name, u8_t id){  err_t err;  struct dns_hdr *hdr;  struct dns_query qry;  struct pbuf *p;  char *query, *nptr;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂a在线| 亚洲欧美日韩国产综合在线| 在线精品视频免费播放| 成人黄色av网站在线| 国产大陆亚洲精品国产| 丁香婷婷综合色啪| 懂色中文一区二区在线播放| 成人一区在线观看| 99re亚洲国产精品| 在线视频你懂得一区二区三区| 欧美无砖专区一中文字| 67194成人在线观看| 日韩欧美中文字幕制服| 欧美一区三区二区| 精品黑人一区二区三区久久| 精品国产污污免费网站入口| 日本一区二区成人| 亚洲免费观看高清完整版在线观看熊 | 欧洲人成人精品| 在线观看成人免费视频| 欧美久久久久免费| 久久婷婷国产综合国色天香 | 国产风韵犹存在线视精品| www.亚洲免费av| 在线免费观看日韩欧美| 91精品国产免费| 国产免费成人在线视频| 亚洲激情欧美激情| 精品在线亚洲视频| 91免费观看在线| 欧美一级片在线| 亚洲欧洲国产日本综合| 亚洲午夜在线电影| 激情久久五月天| 一区二区在线观看视频 | 日韩av午夜在线观看| 欧美精品一卡二卡| 五月激情综合网| 91精品国产色综合久久| www欧美成人18+| 久久综合99re88久久爱| 亚洲精品日韩一| 极品少妇一区二区| 91免费在线播放| 2021久久国产精品不只是精品| 日韩一区中文字幕| 精品制服美女丁香| 欧美高清dvd| 亚洲天堂精品视频| 国产精品中文字幕日韩精品| 欧美日韩中文国产| 国产精品美女久久久久aⅴ国产馆| 欧美精品一区二区三区一线天视频 | 国产精品1024久久| 91麻豆.com| 久久日韩粉嫩一区二区三区 | 一区二区在线观看视频| 国产综合色产在线精品| 4hu四虎永久在线影院成人| 亚洲同性gay激情无套| 国产毛片一区二区| 欧美va亚洲va| 老司机精品视频一区二区三区| 色哟哟国产精品免费观看| 国产精品美女视频| 国产成人免费xxxxxxxx| 日韩精品专区在线| 另类小说视频一区二区| 欧美一区午夜精品| 日本伊人色综合网| 欧美日韩国产另类不卡| 亚洲一本大道在线| 日本精品一区二区三区高清| 日韩毛片一二三区| 9色porny自拍视频一区二区| 国产精品污www在线观看| 国产精品一品二品| 中文字幕欧美激情一区| 成人精品亚洲人成在线| 中文字幕永久在线不卡| 91社区在线播放| 日韩理论在线观看| 日本精品一级二级| 亚洲国产va精品久久久不卡综合| 欧美日韩一区二区三区高清| 亚洲va在线va天堂| 欧美一区二区视频网站| 久久99日本精品| 久久久五月婷婷| 成人黄色电影在线| 亚洲午夜免费视频| 这里是久久伊人| 国产一区高清在线| 国产精品成人网| 欧美日韩一区二区三区不卡| 青青青爽久久午夜综合久久午夜 | 久久伊99综合婷婷久久伊| 国内精品伊人久久久久av一坑 | 成人av网在线| 一区二区三区毛片| 制服丝袜国产精品| 成人精品gif动图一区| 亚洲欧美日韩国产综合在线| 欧美日韩激情在线| 国产一区二区三区四区在线观看 | 欧美精品日韩一本| 国产一区不卡精品| 亚洲日本成人在线观看| 欧美日韩在线播放三区四区| 国产一区二区免费看| 一区二区三区四区视频精品免费| 欧美日韩综合色| 国产精品18久久久久久久网站| 亚洲欧美偷拍三级| 日韩精品在线网站| 91国偷自产一区二区使用方法| 久久精品免费看| 亚洲国产另类av| 欧美高清在线一区| 欧美一级二级三级蜜桃| 色综合久久天天| 国产精品白丝av| 蜜臀99久久精品久久久久久软件| 国产精品无圣光一区二区| 91麻豆精品国产| 91免费版pro下载短视频| 精品亚洲porn| 一区二区三区欧美久久| 国产精品美女www爽爽爽| 91精品国产综合久久福利| 91视频在线看| 国产大陆a不卡| 久久99热99| 日韩激情视频在线观看| 亚洲免费观看高清完整版在线| 久久久久久久综合| 日韩欧美亚洲国产精品字幕久久久| 91浏览器打开| 99精品偷自拍| eeuss鲁一区二区三区| 国产激情精品久久久第一区二区| 日本伊人色综合网| 亚洲aaa精品| 三级久久三级久久久| 夜夜爽夜夜爽精品视频| 亚洲女厕所小便bbb| ...xxx性欧美| 亚洲视频中文字幕| 亚洲品质自拍视频网站| 综合激情成人伊人| 中文字幕中文字幕在线一区| 久久精品一区八戒影视| 精品国产伦一区二区三区观看体验| 7777精品伊人久久久大香线蕉经典版下载 | 成人福利在线看| 成人免费毛片高清视频| 成人午夜免费电影| eeuss影院一区二区三区 | 欧美性感一类影片在线播放| 91免费看片在线观看| 91九色最新地址| 欧美日韩国产bt| 日韩一二三区视频| 精品噜噜噜噜久久久久久久久试看 | 91精品国产入口| 日韩区在线观看| 久久久久久久综合日本| 国产精品欧美久久久久一区二区| 国产精品色一区二区三区| 中文字幕一区二区三| 亚洲精品日日夜夜| 爽好多水快深点欧美视频| 青草国产精品久久久久久| 免费欧美在线视频| 处破女av一区二区| 色偷偷88欧美精品久久久| 欧美日韩精品欧美日韩精品一| 日韩一区二区麻豆国产| 精品免费日韩av| 国产精品久久久久久久裸模| 亚洲一区二区欧美激情| 裸体一区二区三区| 成人久久18免费网站麻豆| 欧美自拍偷拍一区| 亚洲精品在线免费观看视频| 亚洲视频一二三区| 日韩不卡在线观看日韩不卡视频| 国产老女人精品毛片久久| 91麻豆免费在线观看| 日韩一区二区三区高清免费看看| 国产日韩欧美综合在线| 亚洲第一会所有码转帖| 国产精品一二三四| 欧美日韩亚洲另类| 国产欧美日韩精品一区| 亚洲电影中文字幕在线观看| 国产激情一区二区三区四区| 欧美三级在线视频| 国产精品初高中害羞小美女文| 蜜桃视频一区二区三区|