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

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

?? dns.c

?? uCOSII2.84在at91sam9263的移植
?? 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一区二区三区免费野_久草精品视频
久久综合久久鬼色中文字| 国产亚洲欧美在线| 久久色.com| 午夜精品福利在线| 成人永久看片免费视频天堂| 精品视频一区二区三区免费| 欧美激情在线一区二区| 日韩精品亚洲一区二区三区免费| 不卡av电影在线播放| 精品国产凹凸成av人导航| 亚洲自拍偷拍麻豆| gogogo免费视频观看亚洲一| 精品久久久久久综合日本欧美| 一区二区三区四区在线播放| 国产激情视频一区二区三区欧美| 欧美日韩精品一二三区| 亚洲人一二三区| 国产成人在线视频网址| 精品久久久久久亚洲综合网 | 日韩二区在线观看| 色激情天天射综合网| 国产免费观看久久| 国产盗摄精品一区二区三区在线 | 日本一区二区三区在线不卡| 日韩电影免费在线观看网站| 日本久久电影网| 亚洲人精品午夜| 99久久精品免费看国产 | 成人夜色视频网站在线观看| 日韩精品一区二区三区swag | 亚洲成人久久影院| 色噜噜夜夜夜综合网| 国产精品理伦片| 99久久久国产精品| 亚洲伦理在线免费看| 色94色欧美sute亚洲13| 亚洲天堂av一区| 日本丶国产丶欧美色综合| 亚洲色图20p| 在线一区二区观看| 亚洲国产一区二区三区| 欧美性大战久久久久久久蜜臀| 亚洲一二三四区不卡| 欧美日韩免费观看一区二区三区| 亚洲一区二区三区四区的| 欧美人xxxx| 国产在线一区二区综合免费视频| 亚洲精品在线免费播放| 床上的激情91.| 日韩一区中文字幕| 欧美日韩一区二区不卡| 久久精品国产亚洲一区二区三区| 精品99999| 99热99精品| 婷婷丁香久久五月婷婷| 久久先锋资源网| 99精品1区2区| 日本视频一区二区| 亚洲国产精品传媒在线观看| 在线亚洲免费视频| 国内精品写真在线观看| 亚洲精品综合在线| 精品剧情在线观看| 91亚洲精品乱码久久久久久蜜桃| 一区二区三区免费网站| 精品免费视频.| 色又黄又爽网站www久久| 三级影片在线观看欧美日韩一区二区| 日韩欧美激情四射| 9人人澡人人爽人人精品| 午夜精品在线视频一区| 国产亚洲欧美在线| 欧美日本精品一区二区三区| 国产精品99久久久久久似苏梦涵 | 欧美午夜电影网| 国产精一品亚洲二区在线视频| 亚洲女与黑人做爰| 久久综合九色综合欧美亚洲| 在线日韩国产精品| 丰满白嫩尤物一区二区| 偷拍自拍另类欧美| 1024成人网色www| 欧美成人bangbros| 欧美揉bbbbb揉bbbbb| 丁香六月久久综合狠狠色| 日韩av一级电影| 亚洲精品成人悠悠色影视| 26uuu亚洲| 欧美一区二区精品久久911| 色综合色综合色综合色综合色综合| 免费观看成人av| 亚洲自拍与偷拍| 亚洲视频每日更新| 国产精品久久福利| 26uuu国产日韩综合| 欧美一二三在线| 欧美日韩一区国产| 欧美性猛交xxxx乱大交退制版| 国产99久久久国产精品免费看| 日韩av一级片| 欧美a级理论片| 日日夜夜免费精品视频| 一区二区三区不卡视频| 亚洲婷婷在线视频| 综合久久国产九一剧情麻豆| 久久精品欧美一区二区三区不卡| 欧美一区二区三区在线观看| 欧美日韩精品欧美日韩精品一| 色哦色哦哦色天天综合| 92精品国产成人观看免费| www.亚洲国产| 91视频.com| 一本久道久久综合中文字幕 | 欧美精品在线一区二区三区| 91官网在线观看| 在线精品视频一区二区| 色婷婷久久一区二区三区麻豆| 99久久精品国产一区二区三区| 成+人+亚洲+综合天堂| 暴力调教一区二区三区| 99精品视频一区| 日本精品裸体写真集在线观看| 97se亚洲国产综合自在线| 一本一道久久a久久精品| 在线观看免费一区| 在线成人小视频| 日韩美女在线视频| 久久久久国产精品人| 国产精品进线69影院| 一区二区三区欧美| 免费日本视频一区| 久久精品国产在热久久| 国产不卡在线一区| 91在线丨porny丨国产| 欧美日韩中字一区| 日本一区二区三区久久久久久久久不 | 国产91综合网| 91免费版pro下载短视频| 94-欧美-setu| 日韩精品一区二区三区老鸭窝 | 欧美一级视频精品观看| 久久先锋影音av| 自拍偷自拍亚洲精品播放| 一区二区三区成人在线视频| 日本欧美加勒比视频| 国产xxx精品视频大全| 欧美羞羞免费网站| 日韩免费高清视频| 亚洲欧洲日韩综合一区二区| 亚洲成人激情av| 国产成人免费网站| 欧美色偷偷大香| 2023国产精品| 亚洲一区二区在线免费观看视频| 美女视频一区二区三区| 成人免费黄色在线| 欧美一区2区视频在线观看| 国产精品麻豆欧美日韩ww| 亚洲午夜羞羞片| 国产成人超碰人人澡人人澡| 在线观看日韩精品| 久久精品视频一区二区| 午夜精品视频在线观看| 懂色av一区二区三区免费观看| 欧美在线看片a免费观看| 国产婷婷色一区二区三区四区 | 亚洲欧美日韩国产成人精品影院| 天天综合网 天天综合色| av一区二区三区在线| 日韩视频中午一区| 亚洲一区免费观看| 成人激情黄色小说| 2020国产精品自拍| 亚洲国产精品久久久久婷婷884| 国产成人精品免费在线| 欧美一级日韩一级| 三级欧美韩日大片在线看| 成人app软件下载大全免费| 26uuu精品一区二区| 日本不卡一区二区三区| 在线精品视频一区二区三四| 国产欧美日韩不卡免费| 韩国午夜理伦三级不卡影院| 在线成人午夜影院| 亚洲成人福利片| 在线观看免费成人| 亚洲乱码国产乱码精品精的特点 | 无吗不卡中文字幕| 欧美主播一区二区三区| 136国产福利精品导航| 成人深夜福利app| 国产日韩欧美精品综合| 国产在线精品免费| 精品国产露脸精彩对白| 精品一区二区影视| 2014亚洲片线观看视频免费| 久久99国产精品久久99果冻传媒| 日韩午夜激情免费电影| 日韩二区三区在线观看| 欧美一级二级在线观看|