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

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

?? dns_impl.inl

?? ecos下的gui開發源代碼
?? INL
?? 第 1 頁 / 共 2 頁
字號:
#ifndef CYGONCE_NS_DNS_DNS_IMPL_H
#define CYGONCE_NS_DNS_DNS_IMPL_H
//=============================================================================
//
//      dns_impl.inl
//
//      DNS client code implementation.
//
//=============================================================================
//####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: The code is kept in this separate file to allow it to be
//              used from RedBoot.
//
//####DESCRIPTIONEND####
//
//=============================================================================

#include <cyg/ns/dns/dns_priv.h>

/* Validate a hostname is legal as defined in RFC 1035 */
static int
valid_hostname(const char *hostname)
{
    const char * label;
    const char * label_end;
  
    if (!hostname) {
        return false;
    }
    label = hostname;
    while (*label) {
        if (!isalpha(*label))
            return false;
        label_end = strchr(label, (int)'.') - 1;
        if (label_end == (char *)-1) {
            label_end = strchr(label, (int)'\0') - 1;
        }
        while (label != label_end) {
            if (!isalnum(*label) && (*label != '-')) {
                return false;
            }
            label++;
        }
        label = label_end+1;            /* Move onto the . or the null. */
        if (*label == '.') {            /* Move over the . if there is one */
            label++;
        }
    }
    return true;
}

/* Build a qname structure. The structure consists of pairs of
   <len><label> where <label> is eg ma in tux.ma.tech.ascom.ch. len is
   the length of the label. */
static int 
build_qname(unsigned char *ptr, const char *hostname)
{
    const char *label = hostname;
    char *end_label;
    int total_len = 0;
    int len;
  
    while (*label) {
        end_label = strchr(label, (int)'.') - 1;
        if (end_label == (char *)-1) {
            end_label = strchr(label, (int)'\0') - 1;
        }
        len = end_label - label + 1;
        if (len > 63) {
            return -1;
        }
        *ptr++ = (char) len;            /* Put the length of the label */
        memcpy(ptr, label, len);        /* and now the label */
        ptr += len;
    
        total_len += len +1;
        label = end_label+1;            /* Move onto the . or the null. */
        if (*label == '.') {            /* Move over the . if there is one */
            label++;
        }
    }
    *ptr = 0;                           /* Add the last length of zero
                                           to mark the end */
    return (total_len+1);
}

/* Given a pointer to a qname, find the length of the qname. This is
   the number of bytes needed to represent the qname, not the length
   of the name. A qname is terminated by either a 00, or a pointer
   into another qname. This pointer has the top two bits set. */
static int 
qname_len(unsigned char * qname)
{
    unsigned char * ptr = qname;
    
    while ((*ptr != 0) && ((*ptr & 0xc0) != 0xc0)) {
        ptr += *ptr + 1;
    }
    /* Pointers are two bytes */
    if ((*ptr & 0xc0) == 0xc0) {
        ptr++;
    }
    ptr++;                              /* Skip over the trailing byte */

    return (ptr - qname);
}

/* Build a real name from a qname. Alloc the memory needed and return
   it. Return NULL on error */
char *
real_name(unsigned char *msg, unsigned char *qname)
{
    unsigned char * ptr = qname;
    char * name;
    char * label;
    int len = 0;
    int offset;

    /* First pass works out the length of the name */
    while (*ptr != 0) {
        if ((*ptr & 0xc0) == 0xc0) {
            /* pointer to somewhere else. Follow the pointer */
            offset = ((*ptr & 0x3f) << 8) | *(ptr+1);
            ptr = msg + offset;
        } else {
            len += *ptr + 1;
            ptr += *ptr + 1;
        }
    }

    /* Now allocate the memory needed and copy the host name into it */
    name = alloc_string(len+1);
    if (name) {
        label = name;
        ptr = qname;
        while (*ptr != 0) {
            if ((*ptr & 0xc0) == 0xc0) {
                /* pointer to somewhere else. Follow the pointer */
                offset = ((*ptr & 0x3f) << 8) | *(ptr+1);
                ptr = msg + offset;
            } else {
                len = *ptr;
                memcpy(label, (ptr+1), len);
                label += len;
                *label++ = '.';
                ptr += *ptr + 1;
            }
        }
        *label = '\0';
    }
    return name;
}

/* Build a query message which can be sent to the server. If something
   goes wrong return -1, otherwise the length of the query message */
static int 
build_query(const unsigned char * msg, const char * hostname, short rr_type)
{
    struct dns_header *dns_hdr;
    unsigned char *ptr;
    int len;

    /* Fill out the header */
    dns_hdr = (struct dns_header *) msg;
    dns_hdr->id = htons(id++);
    dns_hdr->rd = true;
    dns_hdr->opcode = DNS_QUERY;
    dns_hdr->qdcount = htons(1);
  
    /* Now the question we want to ask */
    ptr = (unsigned char *)&dns_hdr[1];

    len = build_qname(ptr, hostname);

    if (len < 0) {
        h_errno = NO_RECOVERY;
        return -1;
    }
    ptr += len;

    /* Set the type and class fields */
    *ptr++ = (rr_type >> 8) & 0xff;
    *ptr++ = rr_type & 0xff;
    *ptr++ = (DNS_CLASS_IN >> 8) & 0xff;
    *ptr++ = DNS_CLASS_IN & 0xff;

    len = ptr - msg;

    return len;
}

/* Check if the hostname is actually of dot format. If so convert it 
   and return host entity structure. If not, return NULL. */
static struct hostent *
dot_hostname(const char *hostname)
{
    struct hostent *hent = NULL;
    struct in_addr addr;

    if (inet_aton(hostname, &addr)) {
        hent = alloc_hent();
        if (hent) {
            memcpy(hent->h_addr_list[0], &addr, sizeof(struct in_addr));
            hent->h_addrtype = AF_INET;
            hent->h_length = sizeof(struct in_addr);
            hent->h_name = alloc_string(strlen(hostname)+1);
            if (!hent->h_name) {
                free_hent(hent);
                return NULL;
            }
            strcpy(hent->h_name, hostname);
        }
    }
    return hent;
}

#ifdef CYGPKG_NET_INET6
/* Check if the hostname is actually colon format of IPv6. If so convert it 
   and return host entity structure. If not, return NULL. */
static struct hostent *
colon_hostname(const char *hostname) 
{   
  struct sockaddr_in6 addr;
  struct hostent *hent = NULL;

  if (inet_pton(AF_INET6, hostname, (void *)&addr)) {
    hent = alloc_hent();
    if (hent) {
      memcpy(hent->h_addr_list[0], &addr, sizeof(addr));
      hent->h_addrtype = AF_INET6;
      hent->h_length = sizeof(addr);
      hent->h_name = alloc_string(strlen(hostname)+1);
      if (!hent->h_name) {
        free_hent(hent);
        return NULL;
      }
      strcpy(hent->h_name, hostname);
    }
  }
  return hent;
}
#endif

/* Decode the answer from the server. Returns NULL if failed, or 
   a hostent structure containing different data depending on the
   query type:
    DNS_TYPE_A: 
      h_name:         a pointer to the hostname
      h_addr_list[0]: a pointer to in_addr structure
    DNS_TYPE_PTR:
      h_name:         a pointer to the hostname
      h_addr_list[0]: a pointer to an empty in_addr structure. Caller
                      must fill out!
*/
static struct hostent *
parse_answer(unsigned char * msg, short rr_type)
{
    static struct hostent *hent;
    struct dns_header *dns_hdr;
    struct resource_record rr, *rr_p = NULL;
    unsigned char *qname = NULL;
    unsigned char *ptr;

    dns_hdr = (struct dns_header *)msg;

    if (DNS_REPLY_NAME_ERROR == dns_hdr->rcode) {
        h_errno = HOST_NOT_FOUND;
        return NULL;
    }

    if ((dns_hdr->qr != 1) || 
        (dns_hdr->opcode != DNS_QUERY) ||
        (dns_hdr->rcode != DNS_REPLY_NOERR)) {
        h_errno = NO_RECOVERY;
        return NULL;
    }
  
    dns_hdr->ancount = ntohs(dns_hdr->ancount);
    dns_hdr->qdcount = ntohs(dns_hdr->qdcount);
    ptr = (unsigned char *)&dns_hdr[1];

    /* Skip over the query section */
    if (dns_hdr->qdcount > 0) {
        while (dns_hdr->qdcount) {
            ptr += qname_len(ptr);
            ptr += 4;                   /* skip type & class */
            dns_hdr->qdcount--;
        }
    }  
    /* Skip over the answers resource records to find an answer of the
       correct type. */
    while (dns_hdr->ancount) {
        qname = ptr;
        ptr += qname_len(ptr);
        rr_p = (struct resource_record *)ptr;
        memcpy(&rr, ptr, sizeof(rr));
        if ((rr.rr_type == htons(rr_type)) && 
            (rr.class == htons(DNS_CLASS_IN))) {
            break;
        }
        ptr += sizeof(struct resource_record) - sizeof(rr.rdata) + ntohs(rr.rdlength);
        dns_hdr->ancount--;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产伦精品一区二区三区视频青涩| 91福利社在线观看| 91网站最新地址| 欧美乱熟臀69xxxxxx| 久久精品欧美日韩精品| 午夜精品影院在线观看| 国产高清精品久久久久| 3d动漫精品啪啪1区2区免费| 日韩伦理av电影| 国产美女一区二区三区| 欧美日韩国产高清一区二区三区 | 久久色视频免费观看| 亚洲人一二三区| 国产剧情在线观看一区二区| 欧美精品久久一区| 夜夜嗨av一区二区三区网页| 国产成人免费视频精品含羞草妖精| 4438x成人网最大色成网站| 亚洲精品免费视频| 99久久伊人网影院| 久久影院午夜片一区| 免费在线观看一区二区三区| 日本道精品一区二区三区| 亚洲欧洲国产日韩| 粉嫩欧美一区二区三区高清影视| 日韩欧美精品在线| 美女网站一区二区| 日韩一级大片在线| 午夜久久久久久久久| 欧美系列一区二区| 亚洲成人av中文| 欧美日本一区二区| 天天综合色天天综合色h| 欧美性xxxxxx少妇| 午夜一区二区三区在线观看| 在线观看91视频| 亚洲一区自拍偷拍| 欧美视频精品在线观看| 亚瑟在线精品视频| 91精品久久久久久久99蜜桃| 天堂av在线一区| 欧美一区二区黄色| 精品一区二区三区免费播放| 日韩美女天天操| 国产丶欧美丶日本不卡视频| 国产区在线观看成人精品| 国产xxx精品视频大全| 国产精品午夜电影| 91免费小视频| 午夜日韩在线电影| ww亚洲ww在线观看国产| 国产黄色91视频| 国产精品久久毛片a| 91黄色免费看| 日本不卡视频在线观看| 精品国产一区二区三区久久久蜜月| 九色综合国产一区二区三区| 国产人成亚洲第一网站在线播放 | 久久国产综合精品| 久久九九全国免费| 一本到不卡免费一区二区| 亚洲国产成人高清精品| 日韩三级在线观看| 成人丝袜视频网| 亚洲精品国产a| 精品伦理精品一区| 色狠狠综合天天综合综合| 日韩av中文字幕一区二区三区| wwwwww.欧美系列| 在线免费不卡电影| 国产中文字幕精品| 亚洲一区二区三区自拍| 精品88久久久久88久久久| 91欧美一区二区| 久久国产福利国产秒拍| 亚洲少妇30p| 欧美精品一区二区三区蜜桃视频 | 在线视频你懂得一区二区三区| 偷拍自拍另类欧美| 亚洲欧美综合在线精品| 日韩欧美在线观看一区二区三区| zzijzzij亚洲日本少妇熟睡| 丝袜亚洲另类欧美综合| 国产精品素人视频| 精品国产伦一区二区三区观看方式 | 日韩一区二区在线看| av一区二区三区四区| 蜜臀久久99精品久久久久宅男| 中文字幕一区二区5566日韩| 日韩欧美国产电影| 在线观看成人免费视频| 成人av午夜电影| 久久99精品国产91久久来源 | 中文字幕欧美三区| 91精品国产乱码| 色婷婷精品久久二区二区蜜臀av| 久久99精品国产.久久久久久 | 国产精品午夜电影| 精品福利一区二区三区免费视频| 欧美三级电影在线观看| 91尤物视频在线观看| 国产剧情一区二区| 国产一区二区三区免费看| 日韩激情一区二区| 亚洲国产精品久久人人爱| 亚洲欧洲精品天堂一级| 中文字幕精品三区| 欧美极品美女视频| 亚洲国产精品传媒在线观看| 久久综合av免费| 久久蜜桃av一区二区天堂| 欧美成人官网二区| 欧美xxxx在线观看| 欧美mv和日韩mv的网站| 欧美videos大乳护士334| 日韩欧美国产wwwww| 日韩欧美激情在线| 日韩免费观看高清完整版| 欧美一区二区三区电影| 3d成人动漫网站| 日韩欧美国产三级| 日韩欧美精品在线视频| 精品久久久久久久久久久久久久久| 欧美一级高清大全免费观看| 日韩一区二区三区视频在线| 日韩精品一区二区三区视频播放 | 粗大黑人巨茎大战欧美成人| 国产精品 欧美精品| 大白屁股一区二区视频| 91在线精品秘密一区二区| 91久久精品午夜一区二区| 欧美日韩综合不卡| 欧美一级高清大全免费观看| 欧美mv和日韩mv国产网站| 中文成人综合网| 一区二区久久久| 免费成人av资源网| 色天天综合久久久久综合片| 色狠狠色噜噜噜综合网| 777精品伊人久久久久大香线蕉| 日韩免费性生活视频播放| 日本一区二区免费在线| 亚洲一线二线三线视频| 美女精品一区二区| 国产成人av在线影院| 91在线免费看| 欧美一级一级性生活免费录像| www国产精品av| 亚洲蜜桃精久久久久久久| 天天av天天翘天天综合网色鬼国产 | 国产精品一级二级三级| 91视视频在线直接观看在线看网页在线看| 色系网站成人免费| 欧美精品一区二区三区蜜桃视频| 国产精品九色蝌蚪自拍| 日韩精品视频网| 国产成人av资源| 欧美三级三级三级爽爽爽| 久久蜜臀中文字幕| 午夜精品免费在线| 国产91精品露脸国语对白| 欧美日韩欧美一区二区| 久久久久久久久蜜桃| 午夜国产不卡在线观看视频| 国产一区二区三区观看| 在线免费观看不卡av| 久久久国产一区二区三区四区小说 | 日韩电影在线观看一区| 99re成人在线| 精品99一区二区三区| 亚洲午夜久久久久| 成人免费黄色在线| 日韩精品一区在线观看| 亚洲国产综合色| 99久久er热在这里只有精品66| 日韩免费看的电影| 午夜精品福利一区二区三区av| 不卡的av在线| 国产日韩精品一区二区浪潮av | 欧美日韩国产在线播放网站| 久久亚洲二区三区| 日本在线观看不卡视频| 91国产免费观看| 国产精品久久夜| 国产精品一区二区三区四区| 欧美日韩视频在线第一区| 17c精品麻豆一区二区免费| 国产一区二区毛片| 日韩三级在线观看| 日韩精品欧美精品| 欧美电影一区二区三区| 亚洲综合999| 色综合久久久久网| 中文字幕一区在线观看视频| 成人性生交大片免费看在线播放| 欧美成人免费网站| 国产综合久久久久久鬼色| 欧美第一区第二区| 麻豆91免费看| 日韩亚洲电影在线|