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

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

?? dns.c

?? eCos操作系統(tǒng)源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
//=============================================================================////      dns.c////      DNS client code////=============================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//=============================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   andrew.lunn// Contributors:andrew.lunn, jskov// Date:        2001-09-18// Description: Provides DNS lookup as per RFC 1034/1035.// // Note:        Does only support A and PTR lookups. Maybe add for other//              types as well?////              parse_answer() only returns the first found record.////              Add tracing and assertions.////####DESCRIPTIONEND####////=============================================================================#include <pkgconf/system.h>#ifdef CYGPKG_KERNEL# include <pkgconf/kernel.h># include <cyg/kernel/kapi.h>#endif#include <cyg/hal/drv_api.h>#include <cyg/infra/cyg_type.h>#include <cyg/infra/cyg_trac.h>         /* Tracing support */#include <netdb.h>#include <sys/time.h>#include <sys/types.h>#include <sys/socket.h>#include <arpa/inet.h>#include <ctype.h>#include <unistd.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <cyg/ns/dns/dns_priv.h>static short id = 0;              /* ID of the last query */static int s = -1;                /* Socket to the DNS server */static cyg_drv_mutex_t dns_mutex; /* Mutex to stop multiple queries as once */static cyg_ucount32 ptdindex;     /* Index for the per thread data */static char * domainname=NULL;    /* Domain name used for queries *//* Allocate space for string of length len. Return NULL on failure. */static inline char*alloc_string(int len){    return malloc(len);}static inline voidfree_string(char* s){    free(s);}/* Deallocate the memory taken to hold a hent structure */static voidfree_hent(struct hostent * hent){    if (hent->h_name) {        free_string(hent->h_name);    }    if (hent->h_addr_list) {        int i = 0;        while (hent->h_addr_list[i]) {            free(hent->h_addr_list[i]);            i++;        }        free(hent->h_addr_list);    }    free(hent);}/* Allocate hent structure with room for one in_addr. Returns NULL on   failure. */static struct hostent*alloc_hent(void){    struct hostent *hent;    hent = malloc(sizeof(struct hostent));    if (hent) {        memset(hent, 0, sizeof(struct hostent));        hent->h_addr_list = malloc(sizeof(char *)*2);        if (!hent->h_addr_list) {            free_hent(hent);            return NULL;        }        hent->h_addr_list[0] = malloc(sizeof(struct in_addr));        if (!hent->h_addr_list[0]) {            free_hent(hent);            return NULL;        }        hent->h_addr_list[1] = NULL;    }    return hent;}/* Thread destructor used to free stuff stored in per-thread data slot. */static voidthread_destructor(CYG_ADDRWORD data){    struct hostent *hent;    hent = (struct hostent *)cyg_thread_get_data(ptdindex);    if (hent)        free_hent(hent);    return;    data=data;}/* Store the hent away in the per-thread data. */static voidstore_hent(struct hostent *hent){    // Prevent memory leaks by setting a destructor to be    // called on thread exit to free per-thread data.    cyg_thread_add_destructor( &thread_destructor, 0 );    cyg_thread_set_data(ptdindex, (CYG_ADDRWORD)hent);}/* If there is an answer to an old query, free the memory it uses. */static voidfree_stored_hent(void){    struct hostent *hent;    hent = (struct hostent *)cyg_thread_get_data(ptdindex);    if (hent) {        free_hent(hent);        cyg_thread_set_data(ptdindex, (CYG_ADDRWORD)NULL);        cyg_thread_rem_destructor( &thread_destructor, 0 );    }}/* Send the query to the server and read the response back. Return -1   if it fails, otherwise put the response back in msg and return the   length of the response. */static int send_recv(char * msg, int len, int msglen){    struct dns_header *dns_hdr;    struct timeval timeout;    int finished = false;    int backoff = 1;    fd_set readfds;    int written;    int ret;    CYG_REPORT_FUNCNAMETYPE( "send_recv", "returning %d" );    CYG_REPORT_FUNCARG3( "msg=%08x, len=%d, msglen", msg, len, msglen );    CYG_CHECK_DATA_PTR( msg, "msg is not a valid pointer!" );    dns_hdr = (struct dns_header *) msg;    do {         written = write(s, msg, len);        if (written < 0) {            ret = -1;            break;        }        FD_ZERO(&readfds);        FD_SET(s, &readfds);            timeout.tv_sec = backoff;        timeout.tv_usec = 0;        backoff = backoff << 1;        ret = select(s+1, &readfds, NULL, NULL, &timeout);        if (ret < 0) {            ret = -1;            break;        }        /* Timeout */        if (ret == 0) {            if (backoff > 16) {                h_errno = TRY_AGAIN;                ret = -1;                break;            }        }        if (ret == 1) {            ret = read(s, msg, msglen);            if (ret < 0) {                ret = -1;                break;            }                  /* Reply to an old query. Ignore it */            if (ntohs(dns_hdr->id) != (id-1)) {                continue;            }            finished = true;        }    } while (!finished);    CYG_REPORT_RETVAL( ret );    return ret;}/* Include the DNS client implementation code */#include <cyg/ns/dns/dns_impl.inl>/* (re)Start the DNS client. This opens a socket to the DNS server   who's address is passed in. This address can be either an IPv4 or   IPv6 address. This function can be called multiple times.  If we   are being called a second time we have to be careful to allow any   ongoing lookups to finish before we close the socket and connect to   a different DNS server. The danger here is that we may have to wait   for up to 32 seconds if the DNS server is down.   Each invocation will close any previous connection and make a new   connection to the new server. Note the address of the server must   be in numeric form since its not possible to do a DNS lookup! */int cyg_dns_res_start(char * dns_server) {    static int init =0;    struct addrinfo * res;    int err;    CYG_REPORT_FUNCNAMETYPE( "cyg_dns_res_start", "returning %d" );    CYG_REPORT_FUNCARG1( "dns_server=%s", dns_server );    CYG_CHECK_DATA_PTR( dns_server, "dns_server is not a valid pointer!" );    if (init) {      cyg_drv_mutex_lock(&dns_mutex);      cyg_thread_free_data_index(ptdindex);      if (s >= 0) {        close(s);      }    } else {      init = 1;      cyg_drv_mutex_init(&dns_mutex);      cyg_drv_mutex_lock(&dns_mutex);    }        err = getaddrinfo(dns_server,"domain", NULL, &res);    if (err != 0) {        cyg_drv_mutex_unlock(&dns_mutex);        CYG_REPORT_RETVAL( -1 );        return -1;    }      s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);    if (s == -1) {        cyg_drv_mutex_unlock(&dns_mutex);        freeaddrinfo(res);        CYG_REPORT_RETVAL( -1 );        return -1;    }    if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {        s = -1;        cyg_drv_mutex_unlock(&dns_mutex);        freeaddrinfo(res);        CYG_REPORT_RETVAL( -1 );        return -1;    }    ptdindex = cyg_thread_new_data_index();        cyg_drv_mutex_unlock(&dns_mutex);    freeaddrinfo(res);    CYG_REPORT_RETVAL( 0 );    return 0;}/* This is the old interface to start the resolver. It is only IPv4   capable and so is now deprecated in favor of cyg_dns_res_start().   Initialise the resolver. Open a socket and bind it to the   address of the server.  return -1 if something goes wrong,   otherwise 0. If we are being called a second time we have to be   careful to allow any ongoing lookups to finish before we close the   socket and connect to a different DNS server. The danger here is   that we may have to wait for up to 32 seconds if the DNS server is   down.  */int  cyg_dns_res_init(struct in_addr *dns_server){  char name[20];  unsigned char *bytes = (unsigned char *)dns_server;  int ret;  CYG_REPORT_FUNCNAMETYPE( "cyg_dns_res_init", "returning %d" );  CYG_REPORT_FUNCARG1( "dns_server=%08x", dns_server );  diag_sprintf(name, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]);    ret = cyg_dns_res_start(name);    CYG_REPORT_RETVAL( ret );  return ret;}/* add_answer checks to see if we already have this answer and if not,   adds it to the answers. */static int add_answer(char *rdata, short rr_type, int family,            struct sockaddr addrs[], int num, int used) {    int i;    int found = 0;        for (i = 0; i < used ; i++) {        if ((addrs[i].sa_family == family) &&            !memcmp(addrs[i].sa_data, rdata, addrs[i].sa_len)) {            found = 1;            break;        }    }    if (!found) {        memset(&addrs[used],0,sizeof(addrs[used]));        addrs[used].sa_family = family;                switch(family) {        case AF_INET: {            struct sockaddr_in * addr = (struct sockaddr_in *) &addrs[used];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美三级在线| 国产精品中文欧美| 狠狠色丁香婷婷综合久久片| 99精品热视频| 精品美女一区二区| 亚洲一级片在线观看| 丰满白嫩尤物一区二区| 欧美精品久久99久久在免费线| 国产婷婷一区二区| 日韩国产精品久久久久久亚洲| 不卡的av电影在线观看| 精品国产伦一区二区三区免费| 亚洲最大成人网4388xx| 成人理论电影网| 久久久蜜桃精品| 久久精品理论片| 日韩午夜激情免费电影| 激情欧美一区二区| 欧美中文字幕不卡| 一区二区三区在线视频免费观看 | 香港成人在线视频| 成人视屏免费看| 久久麻豆一区二区| 久久99精品久久久久久国产越南 | 欧美亚洲日本一区| 亚洲男人的天堂一区二区| aaa国产一区| √…a在线天堂一区| 成人高清av在线| 精品欧美一区二区三区精品久久| 日韩国产在线一| 制服丝袜在线91| 日本aⅴ免费视频一区二区三区| 欧美私人免费视频| 亚洲国产精品欧美一二99| 欧美午夜影院一区| 亚洲午夜羞羞片| 欧美美女一区二区| 日本亚洲最大的色成网站www| 欧美视频一区二区三区四区| 亚洲国产aⅴ成人精品无吗| 欧美伊人久久久久久久久影院| 亚洲精品国产品国语在线app| 欧美午夜精品一区| 日本中文字幕一区| 欧美精品一区二区久久婷婷| 国产一区在线不卡| 欧美国产一区视频在线观看| 不卡的看片网站| 亚洲影视资源网| 欧美电影一区二区| 久久成人免费电影| 欧美国产日本视频| 日本高清不卡一区| 麻豆国产一区二区| 久久久久久久久久久久久女国产乱| 国产成人一区在线| 亚洲靠逼com| 日韩一区二区电影| 国产不卡一区视频| 亚洲午夜在线观看视频在线| 欧美成人精品1314www| 成人性生交大片免费看中文| 一个色在线综合| 91精品国产乱码久久蜜臀| 国产成人精品一区二区三区四区 | 免费观看在线色综合| 久久综合中文字幕| 日本精品视频一区二区三区| 男男视频亚洲欧美| 国产精品美女一区二区| 国产一级精品在线| 91天堂素人约啪| 中文字幕中文乱码欧美一区二区| 欧美伊人久久久久久午夜久久久久| 蜜臂av日日欢夜夜爽一区| 国产欧美日韩在线| 欧美男男青年gay1069videost| 国产一区中文字幕| 亚洲成av人片在线观看| 国产精品伦理一区二区| 91麻豆精品国产自产在线观看一区| 成人一区二区三区视频在线观看 | 日韩成人av影视| 国产精品美女久久久久久久| 日韩视频在线你懂得| 91影院在线观看| 国产精品亚洲专一区二区三区 | 久久久亚洲高清| 欧美日本一区二区| 91美女福利视频| 国产成人免费视| 久久精品噜噜噜成人88aⅴ| 一区二区三区精密机械公司| 日本一区二区综合亚洲| 欧美成人一级视频| 91精品欧美综合在线观看最新| 色哟哟国产精品| www.亚洲色图| 从欧美一区二区三区| 国产一区在线精品| 激情文学综合网| 久久精品国产亚洲高清剧情介绍| 亚洲第一二三四区| 亚洲一区二区三区在线看| 亚洲精品v日韩精品| 一区二区在线看| 伊人色综合久久天天| 一区二区日韩av| 亚洲精品国产精品乱码不99| 一区二区三区色| 亚洲综合在线五月| 亚洲一区二区三区四区五区黄| 一区二区三区日本| 亚洲精品va在线观看| 亚洲一区二区三区国产| 亚洲国产成人高清精品| 午夜久久久影院| 日本女优在线视频一区二区| 日本特黄久久久高潮| 精品亚洲porn| 国产福利91精品一区| 高清shemale亚洲人妖| 99精品欧美一区| 色88888久久久久久影院野外 | 免费精品视频在线| 99国产精品久| 成人18视频在线播放| 91在线国产福利| 在线免费观看日本欧美| 欧美麻豆精品久久久久久| 国产精品美女久久久久久久网站| 国产精品国产三级国产专播品爱网 | 亚洲精品乱码久久久久久日本蜜臀| 中文字幕在线一区| 亚洲午夜av在线| 老汉av免费一区二区三区| 成人在线一区二区三区| 色久综合一二码| 欧美精品一卡两卡| 久久久久久**毛片大全| 亚洲婷婷综合色高清在线| 亚洲一区二区偷拍精品| 久久激情五月激情| 成人午夜av电影| 欧美日韩一区三区| 精品福利一区二区三区| 国产精品成人免费在线| 亚洲18影院在线观看| 国产一区啦啦啦在线观看| 99免费精品在线观看| 91麻豆精品国产91久久久久| 久久久国产午夜精品 | 99久久精品国产毛片| 欧美久久久久久蜜桃| 国产精品网友自拍| 首页欧美精品中文字幕| 国产精品99久久久久久久女警 | 午夜激情一区二区| 国产精品一区二区x88av| 欧美日韩视频在线一区二区| wwwwxxxxx欧美| 图片区小说区区亚洲影院| 成人性生交大片免费看中文网站| 欧美老女人在线| 亚洲美女一区二区三区| 麻豆精品蜜桃视频网站| 欧美性猛交xxxx乱大交退制版| 亚洲国产高清在线| 日韩精品亚洲专区| 9l国产精品久久久久麻豆| 日韩亚洲欧美成人一区| 亚洲图片激情小说| 国产成人免费9x9x人网站视频| 欧美一卡二卡在线| 亚洲裸体xxx| 风流少妇一区二区| 亚洲精品一区二区三区影院 | 亚洲欧洲韩国日本视频| 奇米影视一区二区三区小说| 在线观看91视频| 中文字幕日韩一区| 国产大陆精品国产| 欧美一区二区三区啪啪| 亚洲一区二区综合| 99re这里只有精品6| 久久久久久久久久久黄色| 久久国产综合精品| 欧美一区二区黄| 婷婷成人综合网| 欧美日韩另类一区| 亚洲午夜在线视频| 欧美在线观看视频在线| 亚洲激情欧美激情| av欧美精品.com| 日韩一区中文字幕| 99久久er热在这里只有精品66| 国产人妖乱国产精品人妖| 韩国女主播一区| 2019国产精品|