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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dns.c

?? freescale k40/k60 freertos-lwip例程
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/** * @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 {  PACK_STRUCT_FIELD(u16_t id);  PACK_STRUCT_FIELD(u8_t flags1);  PACK_STRUCT_FIELD(u8_t flags2);  PACK_STRUCT_FIELD(u16_t numquestions);  PACK_STRUCT_FIELD(u16_t numanswers);  PACK_STRUCT_FIELD(u16_t numauthrr);  PACK_STRUCT_FIELD(u16_t numextrarr);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif#define SIZEOF_DNS_HDR 12#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. */  PACK_STRUCT_FIELD(u16_t type);  PACK_STRUCT_FIELD(u16_t class);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif#define SIZEOF_DNS_QUERY 4#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. */  PACK_STRUCT_FIELD(u16_t type);  PACK_STRUCT_FIELD(u16_t class);  PACK_STRUCT_FIELD(u32_t ttl);  PACK_STRUCT_FIELD(u16_t len);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES#  include "arch/epstruct.h"#endif#define SIZEOF_DNS_ANSWER 10/** 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;};#if DNS_LOCAL_HOSTLIST/** struct used for local host-list */struct local_hostlist_entry {  /** static hostname */  const char *name;  /** static host address in network byteorder */  u32_t addr;  struct local_hostlist_entry *next;};#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC/** Local host-list. For hostnames in this list, no *  external name resolution is performed */static struct local_hostlist_entry *local_hostlist_dynamic;#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC *//** Defining this allows the local_hostlist_static to be placed in a different * linker section (e.g. FLASH) */#ifndef DNS_LOCAL_HOSTLIST_STORAGE_PRE#define DNS_LOCAL_HOSTLIST_STORAGE_PRE static#endif /* DNS_LOCAL_HOSTLIST_STORAGE_PRE *//** Defining this allows the local_hostlist_static to be placed in a different * linker section (e.g. FLASH) */#ifndef DNS_LOCAL_HOSTLIST_STORAGE_POST#define DNS_LOCAL_HOSTLIST_STORAGE_POST#endif /* DNS_LOCAL_HOSTLIST_STORAGE_POST */DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static[]  DNS_LOCAL_HOSTLIST_STORAGE_POST = DNS_LOCAL_HOSTLIST_INIT;#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */static void dns_init_local();#endif /* DNS_LOCAL_HOSTLIST *//* 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);    }  }#if DNS_LOCAL_HOSTLIST  dns_init_local();#endif}/** * 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();  }}#if DNS_LOCAL_HOSTLISTstatic voiddns_init_local(){#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT)  int i;  struct local_hostlist_entry *entry;  /* Dynamic: copy entries from DNS_LOCAL_HOSTLIST_INIT to list */  struct local_hostlist_entry local_hostlist_init[] = DNS_LOCAL_HOSTLIST_INIT;  for (i = 0; i < sizeof(local_hostlist_init) / sizeof(struct local_hostlist_entry); i++) {    entry = mem_malloc(sizeof(struct local_hostlist_entry));    LWIP_ASSERT("mem-error in dns_init_local", entry != NULL);    if (entry != NULL) {      struct local_hostlist_entry *init_entry = &local_hostlist_init[i];      entry->name = init_entry->name;      entry->addr = init_entry->addr;      entry->next = local_hostlist_dynamic;      local_hostlist_dynamic = entry;    }  }#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */}/** * Scans the local host-list for a hostname. * * @param hostname Hostname to look for in the local host-list * @return The first IP address for the hostname in the local host-list or *         INADDR_NONE if not found. */static u32_tdns_lookup_local(const char *hostname){#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC  struct local_hostlist_entry *entry = local_hostlist_dynamic;  while(entry != NULL) {    if(strcmp(entry->name, hostname) == 0) {      return entry->addr;    }    entry = entry->next;  }#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */  int i;  for (i = 0; i < sizeof(local_hostlist_static) / sizeof(struct local_hostlist_entry); i++) {    if(strcmp(local_hostlist_static[i].name, hostname) == 0) {      return local_hostlist_static[i].addr;    }  }#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */  return INADDR_NONE;}#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC/** Remove all entries from the local host-list for a specific hostname * and/or IP addess * * @param hostname hostname for which entries shall be removed from the local *                 host-list * @param addr address for which entries shall be removed from the local host-list * @return the number of removed entries */intdns_local_removehost(const char *hostname, const struct ip_addr *addr){  int removed = 0;  struct local_hostlist_entry *entry = local_hostlist_dynamic;  struct local_hostlist_entry *last_entry = NULL;  while (entry != NULL) {    if (((hostname == NULL) || !strcmp(entry->name, hostname)) &&        ((addr == NULL) || (entry->addr == addr->addr))) {      struct local_hostlist_entry *free_entry;      if (last_entry != NULL) {        last_entry->next = entry->next;      } else {        local_hostlist_dynamic = entry->next;      }      free_entry = entry;      entry = entry->next;      mem_free(free_entry);      removed++;    } else {      last_entry = entry;      entry = entry->next;    }  }  return removed;}/** * Add a hostname/IP address pair to the local host-list. * Duplicates are not checked. * * @param hostname hostname of the new entry * @param addr IP address of the new entry * @return ERR_OK if succeeded or ERR_MEM on memory error */err_tdns_local_addhost(const char *hostname, const struct ip_addr *addr){  struct local_hostlist_entry *entry;  entry = mem_malloc(sizeof(struct local_hostlist_entry));  if (entry == NULL) {    return ERR_MEM;  }  entry->name = hostname;  entry->addr = addr->addr;  entry->next = local_hostlist_dynamic;  local_hostlist_dynamic = entry;  return ERR_OK;}#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC*/#endif /* DNS_LOCAL_HOSTLIST *//** * 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: != INADDR_NONE) or INADDR_NONE if the hostname *         was not found in the cached dns_table. */static u32_tdns_lookup(const char *name){  u8_t i;#if DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN)  u32_t addr;#endif /* DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) */#if DNS_LOCAL_HOSTLIST  if ((addr = dns_lookup_local(name)) != INADDR_NONE) {    return addr;  }#endif /* DNS_LOCAL_HOSTLIST */#ifdef DNS_LOOKUP_LOCAL_EXTERN  if((addr = DNS_LOOKUP_LOCAL_EXTERN(name)) != INADDR_NONE) {    return addr;  }#endif /* DNS_LOOKUP_LOCAL_EXTERN */  /* 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 INADDR_NONE;}#if DNS_DOES_NAME_CHECK/** * Compare the "dotted" name "query" with the encoded name "response"

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美视频你懂的| 日韩国产欧美在线观看| 欧美电视剧免费全集观看| 欧美日韩国产综合一区二区三区 | 国产在线视频精品一区| 丝瓜av网站精品一区二区| 五月婷婷激情综合网| 亚洲一区在线视频| 日日夜夜免费精品视频| 日韩影视精彩在线| 精品一区二区在线视频| 国产精品99久久久| 国产精品99久| 日本久久电影网| 欧美人狂配大交3d怪物一区| 欧美精品v日韩精品v韩国精品v| 91精品啪在线观看国产60岁| 欧美tickling网站挠脚心| 久久久久久久网| 国产精品毛片a∨一区二区三区| 亚洲欧洲av另类| 性做久久久久久免费观看| 老司机午夜精品99久久| 成人黄色小视频| 欧美日韩欧美一区二区| 欧美大胆人体bbbb| 中文在线一区二区| 亚洲成av人片在线观看无码| 激情综合网最新| 91小视频在线免费看| 在线成人午夜影院| 久久久久综合网| 亚洲成人资源在线| 高清在线观看日韩| 欧美日本在线看| 国产精品久久久久久亚洲伦| 香蕉久久夜色精品国产使用方法 | 成人精品视频一区二区三区| 欧洲精品一区二区三区在线观看| 日韩美女一区二区三区四区| 亚洲免费毛片网站| 国产在线日韩欧美| 欧美日韩不卡一区| 亚洲天堂av一区| 狠狠色综合色综合网络| 欧美三级日韩三级国产三级| 国产欧美日产一区| 美女一区二区在线观看| 色国产精品一区在线观看| 久久久久久久久久电影| 天天射综合影视| 在线影视一区二区三区| 国产精品国产精品国产专区不蜜| 蜜桃精品在线观看| 欧美日韩夫妻久久| 亚洲成人先锋电影| 91成人网在线| 亚洲最大成人综合| 99精品热视频| 亚洲欧美在线另类| 国产黄色成人av| 久久久天堂av| 国产乱对白刺激视频不卡| 日韩一级免费一区| 首页欧美精品中文字幕| 欧美性猛交xxxxxx富婆| 有码一区二区三区| 日本久久电影网| 亚洲欧美一区二区久久| 91蝌蚪porny成人天涯| 欧美激情一区二区三区不卡| 国产成人小视频| 国产精品久久久久久久久果冻传媒| 国内一区二区视频| 欧美精品一区二区久久久| 久久www免费人成看片高清| 欧美成人一区二区| 国产自产视频一区二区三区| 久久嫩草精品久久久精品一| 国产美女一区二区三区| 久久精子c满五个校花| 国产一区二区三区四区五区入口| 欧美精品一区二区久久婷婷| 国产成人鲁色资源国产91色综| 久久精品日韩一区二区三区| 国产成人综合网| 亚洲精品午夜久久久| 精品视频在线免费观看| 天堂成人国产精品一区| 日韩免费电影一区| 国产成人精品免费网站| 亚洲免费在线播放| 在线综合亚洲欧美在线视频| 国产在线乱码一区二区三区| 亚洲国产精华液网站w| 色婷婷综合久久久中文字幕| 丝瓜av网站精品一区二区 | 亚洲美女少妇撒尿| 欧美视频一区二区| 捆绑紧缚一区二区三区视频| 久久久久88色偷偷免费| 欧美中文字幕亚洲一区二区va在线| 蜜臀av一区二区在线免费观看 | 欧美在线|欧美| 免费在线观看一区| 18欧美亚洲精品| 日韩午夜三级在线| av在线不卡网| 久久精品国产精品亚洲红杏| 中文字幕不卡的av| 91精品国产一区二区三区香蕉| 东方欧美亚洲色图在线| 午夜欧美电影在线观看| 国产欧美一区二区三区沐欲| 欧美日韩一区二区三区四区| 国产一区二区三区免费| 亚洲超碰97人人做人人爱| 久久久久国产免费免费| 91麻豆精品国产91久久久更新时间| 国产·精品毛片| 免费在线观看一区二区三区| 一区二区在线免费| 国产欧美日韩一区二区三区在线观看| 欧美综合天天夜夜久久| 99久久亚洲一区二区三区青草| 美女尤物国产一区| 婷婷成人激情在线网| 亚洲久草在线视频| 中文字幕免费不卡| 久久久久青草大香线综合精品| 欧美一区二区三区四区久久| 在线一区二区观看| 99re热视频精品| 国产99精品视频| 国内精品伊人久久久久影院对白| 视频在线在亚洲| 亚洲图片一区二区| 亚洲人妖av一区二区| 欧美激情一区二区三区在线| 久久精品人人做人人爽人人| 日韩免费观看2025年上映的电影| 欧美三级视频在线| 精品视频在线视频| 欧美精品黑人性xxxx| 欧美性猛片aaaaaaa做受| 在线观看国产一区二区| 色999日韩国产欧美一区二区| www.亚洲色图| 91免费观看国产| 色综合中文综合网| 91精品国产高清一区二区三区| 色播五月激情综合网| 色噜噜狠狠一区二区三区果冻| 99国产精品久久久| 色婷婷综合久久久久中文一区二区| thepron国产精品| 色综合网站在线| 91黄色激情网站| 欧美日韩亚洲综合| 欧美日韩你懂得| 欧美一区二区三区日韩| 欧美一区二区日韩| 精品美女一区二区三区| 久久理论电影网| 欧美极品aⅴ影院| 亚洲日本va在线观看| 亚洲成人自拍一区| 麻豆精品视频在线观看视频| 久久99国内精品| 波多野结衣亚洲一区| 99麻豆久久久国产精品免费| 欧美三级电影在线观看| 91精品欧美综合在线观看最新| 欧美精品一区视频| 国产精品美女久久久久aⅴ国产馆| 中文字幕日韩av资源站| 亚洲国产另类av| 国产一区二区不卡| 91蜜桃网址入口| 91精品国产一区二区三区香蕉| 久久精品无码一区二区三区| 国产精品夫妻自拍| 天天色 色综合| 国产98色在线|日韩| 欧洲国内综合视频| 2021中文字幕一区亚洲| 亚洲色图都市小说| 日本大胆欧美人术艺术动态| 成人av网站在线| 69堂成人精品免费视频| 国产欧美一二三区| 午夜久久久影院| youjizz久久| 精品粉嫩超白一线天av| 一区二区成人在线| 久久99精品久久久久久| 欧美色中文字幕| 国产精品国产三级国产aⅴ原创| 亚洲成年人影院| 99久久er热在这里只有精品66|