⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dns_client_cache.h

📁 DNS 的实现代码
💻 H
字号:
/* ############################################################################ (c) Copyright Virata Limited 2001 ## Virata Limited Confidential and Proprietary## The following software source code ("Software") is strictly confidential and# is proprietary to Virata Limited ("Virata").  It may only be read, used,# copied, adapted, modified or otherwise dealt with by you if you have# entered into a confidentiality agreement with Virata and then subject to the# terms of that confidentiality agreement and any other applicable agreement# between you and Virata.  If you are in any doubt as to whether you are # entitled to access, read, use, copy, adapt, modify or otherwise deal with# the Software or whether you are entitled to disclose the Software to any# other person you should contact Virata.  If you have not entered into a# confidentiality agreement with Virata granting access to this Software you# should forthwith return all media, copies and printed listings containing# the Software to Virata. ## Virata reserves the right to take legal action against you should you breach# the above provisions.## If you are unsure, or to report violations, please contact # support@virata.com# ##########################################################################*//*  * file:  dns_client_cache.h * * description:  this file contains typedefs, defines, prototypes, etc. for *               cacheing DNS nameservers and resource records. * */#ifndef _DNS_CLIENT_CACHE_H#define _DNS_CLIENT_CACHE_H 1#include "dns_client_query.h"/*  * if the cname flag is on, there won't be an IP address or an inverted IP * address, ptr_name will be empty.  note that if cflag is on, then hostname * is actually an alias and cname contains the real name of the host.  this * is done so we can just search on hostname. */typedef struct {    U8   used;                             /* indicates if this slot empty */    U8   cflag;                            /* cname flag, on if domain name is an alias: */    U8   type;                             /* QT_A, QT_CNAME, QT_AAAA or QT_A6                                             * but not Q_NS          */    U8   recursion;                        /* recursion available flag, applys only to NS */    U8   authoritive;                      /* indicates information from authoritive NS */    U8   naddr;                            /* number of IP addresses, and PTRs */    U8   nsflag;                           /* indicates we know this entry is a NS */    U16  nerrflag;                         /* indicates the name doesn't exist */    char cname[NAMEMAX+1];                 /* if cflag set, (this must be only                                             * for CNAME records) this is the hostname */    char hostname[NAMEMAX+1];              /* host's name */    char ptr_name[MAXIPENTRYS][NAMEMAX+1]; /* inverted IP address used for PTR searches */    struct sockaddr_storage          ipaddr[MAXIPENTRYS];              /* host's IP address, or list of IP addresses */    U32  ttl;                              /* this record's time to live */    BITS init_time;                        /* time this record installed in cache */} HostRecord;/* Cache to store NAPTR and SRV records */typedef struct _XX_CacheEnt{    U8      used;                      /* indicates if this slot empty */    U8      qtype;                     /* QTYPE */    U8      authoritative;             /* indicates information is from authoritative NS */    U16     nerrflag;                  /* indicates the name doesn't exist */    char    domain_name[NAMEMAX+1];    /* domain name that is being resolved */    U32     ttl;                       /* lowest ttl of all the RRs kept here */    BITS    init_time;                 /* time this record is installed in cache */    DnsRRec *rrptr;                    /* Linked List of RRs */} XX_CacheEnt;extern int  dns_query_cache_foraddronly(const char *, DnsRRec **);extern int  dns_query_cache_foraddr6only(const char *, DnsRRec **);extern int  dns_query_cache_ns(const char *, NS_t *);extern int  dns_query_cache_byname(const char *, DnsMsg *);extern int  dns_query_cache_byaddr(const char *, DnsMsg *);extern int  dns_create_ns_list(const char *domain, int max, NS_t *list);extern void dns_update_resolver_cache(DnsMsg *dmsg);extern void dns_add_AA2cache(DnsMsg *, int);extern void dns_flush_resolver_cache(void);extern void dns_flush_resolver_entry(const char *);extern void dns_flush_resolver_entry6(const char *);extern void dns_flush_resolver_entry_ip(U32);extern void dns_flush_resolver_entry_ip6(struct in6_addr *);extern void dns_list_cache(void);/* Results code returned by dns_query_cache_byname6() */#define DNS_ANSWER        0  /* cache has resolved the name */#define DNS_NEGATIVE      1  /* cache has found negative answer */#define DNS_CNAMEANSWER   2  /* cache has resolved the name and cname */#define DNS_CNAME         3  /* cache hasn't resolved cname */extern int dns_query_cache_byname6(DnsQuestion *question, DnsMsg *reply);/* * query_cache() * * this routine allows standard types of queries of the cache.  we look at * the DNS question type and call the appropriate routine for that.  idea * is to have a general routine that allows users to use a standard DNS * query type.  this will allow us to add more query types as the need * arises. * * return:  0 for success, and *         -1 indicates an error. */inline static intquery_cache(DnsQuestion *question, DnsMsg *response){    switch(question->q_type) {    case QT_A:        return dns_query_cache_byname(question->q_name, response);    case QT_PTR:        return dns_query_cache_byaddr(question->q_name, response);    default:        return -1;    }}   /* end query_cache() */extern int      dns_query_XX_cache(char *, Qtype, DnsRRec **);extern void     dns_flush_resolver_XX_cache_byname(const char *);extern void     dns_flush_resolver_XX_cache(void);extern void     dns_update_XX_cache(DnsMsg *);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -