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

📄 dns.h.svn-base

📁 域名解析器的实现
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:

/*------------------------------------------------------------------------
 * I32_T  dnsr_get_query_id()
 * Purpose:   get the queue id from List
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                    
I32_T dnsr_get_query_id(PENDING_DNSR_MSG_PTR pMsg);

/*------------------------------------------------------------------------
 * I32_T  dnsr_get_client_qid()
 * Purpose:   get the client query id from List
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                    
I32_T dnsr_get_client_qid(PENDING_DNSR_MSG_PTR pMsg);

/*------------------------------------------------------------------------
 * I32_T  dnsr_add_query()
 * Purpose:   add the pkt to List
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                    
I32_T dnsr_add_query(PENDING_DNSR_MSG_PTR pMsg);

/*------------------------------------------------------------------------
 * BOOLEAN_T  dnsr_clear_query_id()
 * Purpose:   clear the specific query id
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                    
BOOLEAN_T dnsr_clear_query_id(UI32_T query_id);

/*------------------------------------------------------------------------
 * UI32_T  dnsr_check_query_id()
 * Purpose:   check the query list
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                    
UI32_T dnsr_check_query_id(void);

/*------------------------------------------------------------------------
 * I16_T  dnsr_abort()
 * Purpose:   clear the queue list
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                        
void dnsr_abort(void);

/*------------------------------------------------------------------------
 * I16_T  retrieve_query_by_id()
 * Purpose:   get packet content from index
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                       
void *retrieve_query_by_id(I16_T idx);


/*------------------------------------------------------------------------
 * BOOLEAN_T  dns_ask()
 * Purpose:  handle DNS request packet.   
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                       
BOOLEAN_T dns_ask(unsigned char *qname,  
                   PENDING_DNSR_MSG_PTR pMsg
                  );
                  
/*------------------------------------------------------------------------
 * I16_T  dns_receive()
 * Purpose: handle DNS reply packet.
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                       
int dns_receive(PENDING_DNSR_MSG_PTR pMsg,                            
                struct dns_header *hdr,
                unsigned char *msg,
                unsigned msg_len);                  
                  

/*
 * Called in various places to upcall application's error handler and
 * terminate query.
 */

/*
 * Basic query routine, available directly to applications, also used
 * by higher-level query routines.
 */


/*
 * Downcalled by application to abort a DNS query.
 */


/*
 * Given an IP address, get a name.
 */

/*
 * Defined in dns_util.c.
 */

/*
 * Returns error code or length of compressed name.  If buffer is
 * NULL, just skip over name, don't convert it into text format.
 */

int dns_decode_name
  (char *buffer,
   int buffer_length,
   unsigned char *name,
   unsigned char *msg,
   unsigned msg_len);

/*
 * Returns error code or length of encoded name.
 */

int dns_encode_name
  (unsigned char *buffer,
   unsigned buffer_length,
   char *name);

/*
 * Returns error code.
 */

enum dns_error dns_decode_header
  (unsigned char *msg,
   unsigned msg_len,
   struct dns_header *hdr);

/*
 * Returns error code or number of RRs decoded.
 */

int dns_decode_rrs
  (unsigned char *msg,          /* Network message ("packet") */
   unsigned msg_len,            /* Length of message */
   struct dns_header *hdr,      /* DNS header */
   struct dns_rr rr[],          /* Where to put parsed RRs */
   unsigned nrrs,               /* How many there are */   
   UI32_T now);                /* Current time */   

enum dns_error dns_decode_rcode
  (struct dns_header *hdr);

/*
 * Check a DNS response message for legality.
 *
 * Checks message headers.
 *
 * Checks CNAMEs in Answer section to make sure they form a valid path
 * from the QNAME to the name(s) of any other RRs in the Answer section.
 *
 * I can't think of any way that the non-CNAME RRs in the Answer
 * could legitimately have different names from each other, but
 * I'm not going to put such a check into this code until I have
 * time to double check this in the RFCs.
 *
 * Returns status code.
 */

enum dns_error dns_bless_message  
  (unsigned char *msg,          /* Network message ("packet") */
   unsigned msg_len,            /* Length of message */
   struct dns_header *hdr,      /* DNS header */
   struct dns_rr rrs[],         /* RRs from message */
   unsigned n_rrs);              /* Length of rrs[] */
/*
 * Compare two DNS names (internal format).
 *
 * Returns an integer value.  NB: The value returned is -not- like the
 * value returned by the normal C library strcmp() function, because
 * dns_namcmp() has to be able to return error codes as well.  Sorry.
 *
 * Return value will either be an error code (DNS_ERROR_xxx value) or one
 * of the following:
 *    DNS_NAMCMP_LESS:    first argument is "less" than second argument
 *    DNS_NAMCMP_EQUAL:   first argument is "equal" to second argument
 *    DNS_NAMCMP_GREATER: first argument is "greater" than second argument.
 * These correspond to the three return cases of the C strcmp() routine.
 *
 * For the peace of mind of application authors who only want to
 * compare two names for equality, the numeric value of
 * DNS_NAMCMP_EQUAL is hereby and henceforth defined to be zero.
 *
 * The msg and msg_len parameters for either name are ignored if that
 * name doesn't contain any compression pointers.
 */

#define DNS_NAMCMP_LESS         (1)
#define DNS_NAMCMP_EQUAL        (0)
#define DNS_NAMCMP_GREATER      (2)

extern int dns_namcmp
  (unsigned char *name1,
   unsigned char *msg1,
   unsigned msg1_len,
   unsigned char *name2,
   unsigned char *msg2,
   unsigned msg2_len);

/*
 * Compare DNS types and classes.
 */

int dns_t_match
  (unsigned wild,
      unsigned tame);

extern int dns_c_match
  (unsigned wild,
   unsigned tame);

/*
 * Validate DNS RR TTL.  "now" is a normal Attache time value, in milliseconds.
 */

  int dns_ttl_valid
  (struct dns_rr *r,
   UI32_T now);



/*
 * Defined in dns_cash.c.
 */

/*------------------------------------------------------------------------
 * void  dns_gc_init()
 * Purpose:   initialize dns cache
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                     
void dns_gc_init(void);

/*
 * Look for RRs in the cache.
 * Returns number of RRs found or a status code.
 */
/*------------------------------------------------------------------------
 * dns_lookup()
 * Purpose: Routine to look up cache entries.
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                       
 
int dns_lookup
    (unsigned char *qname,        /* Query name */
     unsigned qclass,             /* Query type */
     unsigned qtype,              /* Query class */
     struct dns_rr *rrs[],        /* Where to put results */
     int max_rrs);                 /* Length of rrs[] */

/*
 * Insert some RRs into the cache.
 * Returns a status code.
 */

/*------------------------------------------------------------------------
 * dns_cache_rrs()
 * Purpose: Routine to add all the RRs in a message to the cache.
 *          Returns status code.
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                       
enum dns_error dns_cache_rrs
    (unsigned char *msg,          /* Message containing RRs to cache */
     unsigned msg_len,            /* Length of message */
     struct dns_header *hdr,      /* Decoded DNS header */
     struct dns_rr rrs[],         /* Parsed RRs from msg */
     unsigned n_rrs);
          
/*
 * Insert an error "RR" into the negative response cache.
 * Returns a status code.
 */

/*
 * Mark as dead any RRs whose TTLs have expired, or which are intimately
 * related to RRs whose TTLs have expired.  Does not otherwise modify the
 * cache database, so is safe to run while the application holds pointers
 * into the cache.
 */

void dns_gc_mark(void);

/*
 * Remove from the cache any RRs which have been marked as dead by
 * dns_gc_mark().  Mucks with pointers and frees RR objects, so must not be
 * allowed to run while any part of the application holds pointers into the
 * cache.
 */

void dns_gc_sweep(void);

/*
 * Remove all RRs from the cache, regardless of their timeout state.
 * Mucks with pointers and frees RR objects, so must not be allowed to run
 * while any part of the application holds pointers into the cache.
 */

void dns_gc_nuke(void);

/*------------------------------------------------------------------------
 * UI32_T  dns_check_cache()
 * Purpose: check dns cache
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */                     
UI32_T dns_check_cache(void);

/*
 * Defined in dns_init.c.
 */

/*------------------------------------------------------------------------
 * void  dnsr_init()
 * Purpose: initialize dnsr config
 *          
 * Parameters:
 *    Input:
 *    Output:
 * returns :
 *------------------------------------------------------------------------
 */
void dnsr_init(void);

#endif /* DNS_H */

⌨️ 快捷键说明

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