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

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

?? netdb.c

?? uCOSII2.84在at91sam9263的移植
?? C
字號:
/** * @file * API functions for name resolving * *//* * 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. * * This file is part of the lwIP TCP/IP stack. *  * Author: Simon Goldschmidt * */#include "lwip/netdb.h"#if LWIP_DNS && LWIP_SOCKET#include "lwip/err.h"#include "lwip/mem.h"#include "lwip/ip_addr.h"#include "lwip/api.h"/** helper struct for gethostbyname_r to access the char* buffer */struct gethostbyname_r_helper {  struct ip_addr *addrs;  struct ip_addr addr;  char *aliases;};/** h_errno is exported in netdb.h for access by applications. */#if LWIP_DNS_API_DECLARE_H_ERRNOint h_errno;#endif /* LWIP_DNS_API_DECLARE_H_ERRNO *//** define "hostent" variables storage: 0 if we use a static (but unprotected) * set of variables for lwip_gethostbyname, 1 if we use a local storage */#ifndef LWIP_DNS_API_HOSTENT_STORAGE#define LWIP_DNS_API_HOSTENT_STORAGE 0#endif/** define "hostent" variables storage */#if LWIP_DNS_API_HOSTENT_STORAGE#define HOSTENT_STORAGE#else#define HOSTENT_STORAGE static#endif /* LWIP_DNS_API_STATIC_HOSTENT *//** * Returns an entry containing addresses of address family AF_INET * for the host with name name. * Due to dns_gethostbyname limitations, only one address is returned. * * @param name the hostname to resolve * @return an entry containing addresses of address family AF_INET *         for the host with name name */struct hostent*lwip_gethostbyname(const char *name){  err_t err;  struct ip_addr addr;  /* buffer variables for lwip_gethostbyname() */  HOSTENT_STORAGE struct hostent s_hostent;  HOSTENT_STORAGE char *s_aliases;  HOSTENT_STORAGE struct ip_addr s_hostent_addr;  HOSTENT_STORAGE struct ip_addr *s_phostent_addr;  /* query host IP address */  err = netconn_gethostbyname(name, &addr);  if (err != ERR_OK) {    LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));    h_errno = HOST_NOT_FOUND;    return NULL;  }  /* fill hostent */  s_hostent_addr = addr;  s_phostent_addr = &s_hostent_addr;  s_hostent.h_name = (char*)name;  s_hostent.h_aliases = &s_aliases;  s_hostent.h_addrtype = AF_INET;  s_hostent.h_length = sizeof(struct ip_addr);  s_hostent.h_addr_list = (char**)&s_phostent_addr;#if DNS_DEBUG  /* dump hostent */  LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_name           == %s\n",      s_hostent.h_name));  LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases        == 0x%08lX\n",(u32_t)(s_hostent.h_aliases)));  if (s_hostent.h_aliases != NULL) {    u8_t idx;    for ( idx=0; s_hostent.h_aliases[idx]; idx++) {      LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]->   == 0x%08lX\n", idx, s_hostent.h_aliases[idx]));      LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]->   == %s\n",      idx, s_hostent.h_aliases[idx]));    }  }  LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addrtype       == %lu\n",    (u32_t)(s_hostent.h_addrtype)));  LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_length         == %lu\n",    (u32_t)(s_hostent.h_length)));  LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list      == 0x%08lX\n", s_hostent.h_addr_list));  if (s_hostent.h_addr_list != NULL) {    u8_t idx;    for ( idx=0; s_hostent.h_addr_list[idx]; idx++) {      LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]   == 0x%08lX\n", idx, s_hostent.h_addr_list[idx]));      LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n",      idx, inet_ntoa(*((struct in_addr*)(s_hostent.h_addr_list[idx])))));    }  }#endif /* DNS_DEBUG */#if LWIP_DNS_API_HOSTENT_STORAGE  /* this function should return the "per-thread" hostent after copy from s_hostent */  return sys_thread_hostent(&s_hostent);#else  return &s_hostent;#endif /* LWIP_DNS_API_HOSTENT_STORAGE */}/** * Thread-safe variant of lwip_gethostbyname: instead of using a static * buffer, this function takes buffer and errno pointers as arguments * and uses these for the result. * * @param name the hostname to resolve * @param ret pre-allocated struct where to store the result * @param buf pre-allocated buffer where to store additional data * @param buflen the size of buf * @param result pointer to a hostent pointer that is set to ret on success *               and set to zero on error * @param h_errnop pointer to an int where to store errors (instead of modifying *                 the global h_errno) * @return 0 on success, non-zero on error, additional error information *         is stored in *h_errnop instead of h_errno to be thread-safe */intlwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,                size_t buflen, struct hostent **result, int *h_errnop){  err_t err;  struct gethostbyname_r_helper *h;  char *hostname;  size_t namelen;  int lh_errno;  if (h_errnop == NULL) {    /* ensure h_errnop is never NULL */    h_errnop = &lh_errno;  }  if (result == NULL) {    /* not all arguments given */    *h_errnop = EINVAL;    return -1;  }  /* first thing to do: set *result to nothing */  *result = NULL;  if ((name == NULL) || (ret == NULL) || (buf == 0)) {    /* not all arguments given */    *h_errnop = EINVAL;    return -1;  }  namelen = strlen(name);  if (buflen < (sizeof(struct gethostbyname_r_helper) + namelen + 1 + (MEM_ALIGNMENT - 1))) {    /* buf can't hold the data needed + a copy of name */    *h_errnop = ERANGE;    return -1;  }  h = (struct gethostbyname_r_helper*)LWIP_MEM_ALIGN(buf);  hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper);  /* query host IP address */  err = netconn_gethostbyname(name, &(h->addr));  if (err != ERR_OK) {    LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));    *h_errnop = ENSRNOTFOUND;    return -1;  }  /* copy the hostname into buf */  MEMCPY(hostname, name, namelen);  hostname[namelen] = 0;  /* fill hostent */  h->addrs = &(h->addr);  h->aliases = NULL;  ret->h_name = (char*)hostname;  ret->h_aliases = &(h->aliases);  ret->h_addrtype = AF_INET;  ret->h_length = sizeof(struct ip_addr);  ret->h_addr_list = (char**)&(h->addrs);  /* set result != NULL */  *result = ret;  /* return success */  return 0;}/** * Frees one or more addrinfo structures returned by getaddrinfo(), along with * any additional storage associated with those structures. If the ai_next field * of the structure is not null, the entire list of structures is freed. * * @param ai struct addrinfo to free */voidlwip_freeaddrinfo(struct addrinfo *ai){  struct addrinfo *next;  while (ai != NULL) {    if (ai->ai_addr != NULL) {      mem_free(ai->ai_addr);    }    if (ai->ai_canonname != NULL) {      mem_free(ai->ai_canonname);    }    next = ai->ai_next;    mem_free(ai);    ai = next;  }}/** * Translates the name of a service location (for example, a host name) and/or * a service name and returns a set of socket addresses and associated * information to be used in creating a socket with which to address the * specified service. * Memory for the result is allocated internally and must be freed by calling * lwip_freeaddrinfo()! * * Due to a limitation in dns_gethostbyname, only the first address of a * host is returned. * Also, service names are not supported (only port numbers)! * * @param nodename descriptive name or address string of the host *                 (may be NULL -> local address) * @param servname port number as string of NULL  * @param hints structure containing input values that set socktype and protocol * @param res pointer to a pointer where to store the result (set to NULL on failure) * @return 0 on success, non-zero on failure */intlwip_getaddrinfo(const char *nodename, const char *servname,       const struct addrinfo *hints, struct addrinfo **res){  err_t err;  struct ip_addr addr;  struct addrinfo *ai;  struct sockaddr_in *sa = NULL;  int port_nr = 0;  if (res == NULL) {    return EAI_FAIL;  }  *res = NULL;  if ((nodename == NULL) && (servname == NULL)) {    return EAI_NONAME;  }  if (servname != NULL) {    /* service name specified: convert to port number     * @todo?: currently, only ASCII integers (port numbers) are supported! */    port_nr = atoi(servname);    if ((port_nr <= 0) || (port_nr > 0xffff)) {      return EAI_SERVICE;    }  }  if (nodename != NULL) {    /* service location specified, try to resolve */    err = netconn_gethostbyname(nodename, &addr);    if (err != ERR_OK) {      return EAI_FAIL;    }  } else {    /* service location specified, use loopback address */    addr.addr = INADDR_LOOPBACK;  }  ai = mem_malloc(sizeof(struct addrinfo));  if (ai == NULL) {    goto memerr;  }  memset(ai, 0, sizeof(struct addrinfo));  sa = mem_malloc(sizeof(struct sockaddr_in));  if (sa == NULL) {    goto memerr;  }  memset(sa, 0, sizeof(struct sockaddr_in));  /* set up sockaddr */  sa->sin_addr.s_addr = addr.addr;  sa->sin_family = AF_INET;  sa->sin_len = sizeof(struct sockaddr_in);  sa->sin_port = htons(port_nr);  /* set up addrinfo */  ai->ai_family = AF_INET;  if (hints != NULL) {    /* copy socktype & protocol from hints if specified */    ai->ai_socktype = hints->ai_socktype;    ai->ai_protocol = hints->ai_protocol;  }  if (nodename != NULL) {    /* copy nodename to canonname if specified */    size_t namelen = strlen(nodename);    ai->ai_canonname = mem_malloc(namelen + 1);    if (ai->ai_canonname == NULL) {      goto memerr;    }    MEMCPY(ai->ai_canonname, nodename, namelen);    ai->ai_canonname[namelen] = 0;  }  ai->ai_addrlen = sizeof(struct sockaddr_in);  ai->ai_addr = (struct sockaddr*)sa;  *res = ai;  return 0;memerr:  if (ai != NULL) {    mem_free(ai);  }  if (sa != NULL) {    mem_free(sa);  }  return EAI_MEMORY;}#endif /* LWIP_DNS && LWIP_SOCKET */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野洁衣一区| 久久综合色综合88| 日韩免费福利电影在线观看| 国产欧美1区2区3区| 亚洲超碰精品一区二区| 99久久久国产精品| 久久综合色8888| 婷婷综合另类小说色区| 99久久精品国产网站| 精品成人一区二区三区| 午夜精品aaa| 99re这里只有精品首页| 国产清纯美女被跳蛋高潮一区二区久久w | 亚洲国产精品精华液ab| 麻豆成人免费电影| 欧美色图免费看| 中文字幕人成不卡一区| 国产电影一区二区三区| 日韩亚洲电影在线| 日韩电影一二三区| 日本精品一区二区三区四区的功能| 精品国产一区二区亚洲人成毛片| 亚洲国产中文字幕在线视频综合 | 日本色综合中文字幕| 色综合av在线| 亚洲乱码国产乱码精品精可以看| 国产福利一区二区三区视频| 26uuu精品一区二区三区四区在线| 石原莉奈在线亚洲三区| 欧美情侣在线播放| 五月天一区二区| 欧美性videosxxxxx| 亚洲成人第一页| 欧美日韩中文字幕精品| 亚洲国产日韩a在线播放| 欧美亚洲国产怡红院影院| 亚洲免费视频成人| 91精品办公室少妇高潮对白| 亚洲视频一二三区| 91色在线porny| 亚洲综合色婷婷| 欧美二区三区91| 青青草国产成人99久久| 欧美一级二级三级乱码| 经典一区二区三区| 国产精品嫩草99a| av电影天堂一区二区在线| 有码一区二区三区| 欧美午夜片在线观看| 蜜臀91精品一区二区三区| 久久综合九色综合97婷婷| 国产一区二区三区视频在线播放| 国产欧美精品国产国产专区| 91视频国产观看| 视频精品一区二区| 久久免费午夜影院| 色婷婷综合久久久| 毛片av中文字幕一区二区| 精品久久人人做人人爰| a4yy欧美一区二区三区| 丝袜亚洲精品中文字幕一区| xvideos.蜜桃一区二区| 一本到高清视频免费精品| 美日韩一区二区| 国产精品伦一区| 欧美精品电影在线播放| 国产乱对白刺激视频不卡| 最新国产精品久久精品| 欧美精品乱码久久久久久按摩| 国产激情视频一区二区在线观看| 国产精品精品国产色婷婷| 欧美日本一区二区三区四区| 韩日av一区二区| 亚洲午夜久久久久中文字幕久| 日韩精品一区二区在线| 91在线高清观看| 精品亚洲免费视频| 一区二区在线免费| 久久免费国产精品| 欧美三电影在线| 成人免费毛片片v| 欧美aaa在线| 亚洲永久免费视频| 国产偷国产偷精品高清尤物| 欧美日韩在线三区| aa级大片欧美| 韩国精品一区二区| 日韩精品亚洲一区二区三区免费| 中文字幕一区二区三区不卡在线| 91精品国产色综合久久| 色综合天天综合给合国产| 国产精品白丝jk白祙喷水网站| 天天色图综合网| 亚洲欧美另类综合偷拍| 国产欧美一区二区精品性色超碰| 91精品一区二区三区久久久久久| 91在线观看免费视频| 国产成人免费av在线| 国产主播一区二区| 青青草国产精品亚洲专区无| 午夜精品一区二区三区免费视频| 国产精品久久久久国产精品日日| 久久久久久99久久久精品网站| 欧美一区二区三区视频| 欧美日本国产视频| 欧美体内she精视频| 欧美亚洲国产一区二区三区va| av日韩在线网站| 不卡视频一二三| 99精品欧美一区二区三区小说 | 日韩中文字幕av电影| 亚洲欧美日韩一区二区三区在线观看 | 久久爱另类一区二区小说| 亚洲综合999| 一区二区在线电影| 亚洲人成精品久久久久久 | 五月婷婷激情综合网| 亚洲一区av在线| 亚洲一区二区三区四区五区黄 | 奇米一区二区三区| 五月天国产精品| 麻豆国产91在线播放| 国内成人自拍视频| 国产成人在线视频播放| 成人精品国产免费网站| 不卡视频一二三四| 在线观看日韩高清av| 欧美日韩久久不卡| 日韩欧美一区在线| 精品国产91洋老外米糕| 久久久电影一区二区三区| 中文字幕欧美激情| 日韩av网站免费在线| 亚洲国产美国国产综合一区二区| 亚洲妇女屁股眼交7| 日本欧美一区二区在线观看| 精东粉嫩av免费一区二区三区| 国产精品中文字幕欧美| eeuss鲁片一区二区三区在线观看| 一本到高清视频免费精品| 欧美日韩国产一二三| 日韩精品一区二区三区中文精品| 久久女同性恋中文字幕| 成人欧美一区二区三区小说| 亚洲va欧美va人人爽午夜| 男人操女人的视频在线观看欧美| 国产精品一区二区男女羞羞无遮挡| 成人av在线看| 欧美亚州韩日在线看免费版国语版| 6080日韩午夜伦伦午夜伦| 国产日产欧产精品推荐色 | 亚洲va欧美va天堂v国产综合| 免费观看30秒视频久久| 99久久久免费精品国产一区二区| 欧美美女一区二区| 久久综合九色综合欧美就去吻 | 精品动漫一区二区三区在线观看| 国产精品灌醉下药二区| 亚洲成人一区二区| 韩国欧美国产一区| 欧美日韩精品欧美日韩精品一| 精品国产麻豆免费人成网站| 国产精品美女久久久久久| 丝袜亚洲另类欧美综合| 99久久夜色精品国产网站| 欧美一区中文字幕| 亚洲欧美一区二区三区久本道91| 美洲天堂一区二卡三卡四卡视频| 91玉足脚交白嫩脚丫在线播放| 欧美成人精品福利| 亚洲高清在线视频| fc2成人免费人成在线观看播放| 欧美一区二区三区播放老司机| 综合网在线视频| 国产99久久久国产精品| 91麻豆精品国产自产在线观看一区| 中文字幕视频一区二区三区久| 国产一区亚洲一区| 日韩欧美不卡在线观看视频| 亚洲欧美日韩电影| 成人激情午夜影院| 精品国产伦一区二区三区观看体验 | 日韩成人精品在线观看| 91浏览器入口在线观看| 久久午夜羞羞影院免费观看| 日本不卡视频在线观看| 欧美日韩1234| 亚洲gay无套男同| 欧美视频一区二区在线观看| 亚洲女子a中天字幕| k8久久久一区二区三区| 国产日本欧美一区二区| 国产伦精品一区二区三区视频青涩 | 久久新电视剧免费观看| 蜜桃视频在线一区| 欧美精品欧美精品系列| 亚洲1区2区3区4区| 欧美视频在线一区二区三区 | 国产电影一区在线| 久久久久久9999|