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

📄 dns_client_resource.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_resource.h * * description:  this file contains typedefs and externs for the resources *               used by the dns client.  note that none of this would be *               necessary if there was a efficient malloc() and free() as *               part of the ISOS package.  if and when one becomes available *               this should be replaced. */#ifndef _DNS_CLIENT_RESOURSE_H#define _DNS_CLIENT_RESOURSE_H#include "atypes.h"#include "dns_client_query.h"     /* includes dns_resolv.h for struct dns_hostent */#define IPSIZE      sizeof(U32)#define IP6SIZE     sizeof(struct in6_addr)#define TXBUFMAX    5/* this structure is used to provide memory for nslookup commands. */typedef struct {    long                used;    struct dns_hostent  hent;    struct hostent     *hent6;     /* for IPv6 only */    ATMOS_MESSAGE       amsg;    char                name[NAMEMAX+1];    U32                 addrs[ENTADDRS];} nslook_t;/* Prototype of callback for QueryState */typedef void (*dns_client_query_callback)(QueryState *);/* externs */#ifdef DNS_DEBUGextern void print_resource_pool(void);#endifextern U8           *dns_ip_alloc(void);extern U8           *dns_ip6_alloc(void);extern void         dns_ip_free(U8 *);extern U8           *dns_name_alloc(void);extern void         dns_name_free(U8 *);extern DnsQuestion  *dns_get_question(void);extern void         dns_free_question(DnsQuestion *);extern DnsRRec      *dns_get_RR(void);extern void         dns_free_RR(DnsRRec *);extern SOArec       *dns_get_SOA(void);extern void         dns_free_SOA(SOArec *);extern void         dns_cache_init(void);/* * dns_alloc_struct_hostent() * * this routine dynamically allocates memory for struct hostent. * * returns pointer to allocated area *         or NULL on failure */extern struct hostent *dns_alloc_struct_hostent(void);/* * dns_alloc_hostname() * * this routine dynamically allocates memory for 'h_name' field of * hostent structure. * * note, that upon failure, this function RELEASES hostent structure. * caller then has to set pointer to this structure to NULL. * * parameters: *     hent     - pointer to hostent structure *     hostname - hostname to install * * returns pointer to allocated area *         or NULL on failure */extern const char *dns_alloc_hostname(struct hostent *hent,                                       const char *hostname);/* * dns_alloc_aliases() * * this routine dynamically allocates memory for 'h_aliases' field of * hostent structure.  * * note, however, that memory for aliases themselves is not allocated * (since we can not know in advance lengthes of all aliases). * * note, that on failure, this function RELEASES hostent structure. * caller then has to set pointer to this structure to NULL. * * returns pointer to the allocated area  *         or NULL on failure */extern char **dns_alloc_aliases(struct hostent *hent, int num_aliases);/* * dns_alloc_addrlist() * * this routine dynamically allocates memory for 'h_addr_list' field * of hostent structure and for 'num_addr' addresses of type 'type' in * it. * * note, in case of failure, this function RELEASES hostent structure. * caller then has to set pointer to this structure to NULL. * * returns pointer to the allocated area  *         or NULL on failure */extern char **dns_alloc_addrlist(struct hostent *hent,                                  int num_addr, int afamily);/* * dns_dalloc() * * this routine will either allocate an IP address or a name.  the IP address * is a pointer to a U32 and the name is a character array. * * return:  pointer to allocated space, or *          NULL if none available. */static inline U8 *dns_dalloc(int size){    if (size <= (int)IPSIZE)         return dns_ip_alloc();    else if (size == (int)IP6SIZE)        return dns_ip6_alloc();    else        return dns_name_alloc();}   /* end dalloc() *//* * dns_dfree() * * this routine will release the name or IP address.  the routine uses the * size parameter to determine the memory type. */ static inline voiddns_dfree(U8 *data, int size){    if (size <= (int)IPSIZE || size == (int)IP6SIZE)         dns_ip_free(data);    else        dns_name_free(data);}    /* end dns_dfree() */        #endif

⌨️ 快捷键说明

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