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

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

?? dns.h

?? 一個開源SIP協議棧
?? H
字號:
/* $Id: dns.h 1033 2007-03-02 14:51:03Z bennylp $ */
/* 
 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
 *
 * This program 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 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */
#ifndef __PJLIB_UTIL_DNS_H__
#define __PJLIB_UTIL_DNS_H__


/**
 * @file dns.h
 * @brief Low level DNS message parsing and packetization.
 */
#include <pjlib-util/types.h>
#include <pj/sock.h>

PJ_BEGIN_DECL

/**
 * @defgroup PJ_DNS DNS and Asynchronous DNS Resolver
 * @ingroup PJLIB_UTIL
 */

/**
 * @defgroup PJ_DNS_PARSING Low-level DNS Message Parsing and Packetization
 * @ingroup PJ_DNS
 * @{
 *
 * This module provides low-level services to parse and packetize DNS queries
 * and responses. The functions support building a DNS query packet and parse
 * the data in the DNS response.
 *
 * To create a DNS query packet, application should call #pj_dns_make_query()
 * function, specifying the desired DNS query type, the name to be resolved,
 * and the buffer where the DNS packet will be built into. 
 *
 * When incoming DNS query or response packet arrives, application can use
 * #pj_dns_parse_packet() to parse the TCP/UDP payload into parsed DNS packet
 * structure.
 *
 * This module does not provide any networking functionalities to send or
 * receive DNS packets. This functionality should be provided by higher layer
 * modules such as @ref PJ_DNS_RESOLVER.
 */

enum
{
    PJ_DNS_CLASS_IN	= 1	/**< DNS class IN.			    */
};

/**
 * This enumeration describes standard DNS record types as described by
 * RFC 1035, RFC 2782, and others.
 */
typedef enum pj_dns_type
{
    PJ_DNS_TYPE_A	= 1,    /**< Host address (A) record.		    */
    PJ_DNS_TYPE_NS	= 2,    /**< Authoritative name server (NS)	    */
    PJ_DNS_TYPE_MD	= 3,    /**< Mail destination (MD) record.	    */
    PJ_DNS_TYPE_MF	= 4,    /**< Mail forwarder (MF) record.	    */
    PJ_DNS_TYPE_CNAME	= 5,	/**< Canonical name (CNAME) record.	    */
    PJ_DNS_TYPE_SOA	= 6,    /**< Marks start of zone authority.	    */
    PJ_DNS_TYPE_MB	= 7,    /**< Mailbox domain name (MB).		    */
    PJ_DNS_TYPE_MG	= 8,    /**< Mail group member (MG).		    */
    PJ_DNS_TYPE_MR	= 9,    /**< Mail rename domain name.		    */
    PJ_DNS_TYPE_NULL	= 10,	/**< NULL RR.				    */
    PJ_DNS_TYPE_WKS	= 11,	/**< Well known service description	    */
    PJ_DNS_TYPE_PTR	= 12,	/**< Domain name pointer.		    */
    PJ_DNS_TYPE_HINFO	= 13,	/**< Host information.			    */
    PJ_DNS_TYPE_MINFO	= 14,	/**< Mailbox or mail list information.	    */
    PJ_DNS_TYPE_MX	= 15,	/**< Mail exchange record.		    */
    PJ_DNS_TYPE_TXT	= 16,	/**< Text string.			    */
    PJ_DNS_TYPE_RP	= 17,	/**< Responsible person.		    */
    PJ_DNS_TYPE_AFSB	= 18,	/**< AFS cell database.			    */
    PJ_DNS_TYPE_X25	= 19,	/**< X.25 calling address.		    */
    PJ_DNS_TYPE_ISDN	= 20,	/**< ISDN calling address.		    */
    PJ_DNS_TYPE_RT	= 21,	/**< Router.				    */
    PJ_DNS_TYPE_NSAP	= 22,	/**< NSAP address.			    */
    PJ_DNS_TYPE_NSAP_PTR= 23,	/**< NSAP reverse address.		    */
    PJ_DNS_TYPE_SIG	= 24,	/**< Signature.				    */
    PJ_DNS_TYPE_KEY	= 25,	/**< Key.				    */
    PJ_DNS_TYPE_PX	= 26,	/**< X.400 mail mapping.		    */
    PJ_DNS_TYPE_GPOS	= 27,	/**< Geographical position (withdrawn)	    */
    PJ_DNS_TYPE_AAAA	= 28,	/**< IPv6 address.			    */
    PJ_DNS_TYPE_LOC	= 29,	/**< Location.				    */
    PJ_DNS_TYPE_NXT	= 30,	/**< Next valid name in the zone.	    */
    PJ_DNS_TYPE_EID	= 31,	/**< Endpoint idenfitier.		    */
    PJ_DNS_TYPE_NIMLOC	= 32,	/**< Nimrod locator.			    */
    PJ_DNS_TYPE_SRV	= 33,	/**< Server selection (SRV) record.	    */
    PJ_DNS_TYPE_ATMA	= 34,	/**< DNS ATM address record.		    */
    PJ_DNS_TYPE_NAPTR	= 35,	/**< DNS Naming authority pointer record.   */
    PJ_DNS_TYPE_KX	= 36,	/**< DNS key exchange record.		    */
    PJ_DNS_TYPE_CERT	= 37,	/**< DNS certificate record.		    */
    PJ_DNS_TYPE_A6	= 38,	/**< DNS IPv6 address (experimental)	    */
    PJ_DNS_TYPE_DNAME	= 39,	/**< DNS non-terminal name redirection rec. */

    PJ_DNS_TYPE_OPT	= 41,	/**< DNS options - contains EDNS metadata.  */
    PJ_DNS_TYPE_APL	= 42,	/**< DNS Address Prefix List (APL) record.  */
    PJ_DNS_TYPE_DS	= 43,	/**< DNS Delegation Signer (DS)		    */
    PJ_DNS_TYPE_SSHFP	= 44,	/**< DNS SSH Key Fingerprint		    */
    PJ_DNS_TYPE_IPSECKEY= 45,	/**< DNS IPSEC Key.			    */
    PJ_DNS_TYPE_RRSIG	= 46,	/**< DNS Resource Record signature.	    */
    PJ_DNS_TYPE_NSEC	= 47,	/**< DNS Next Secure Name.		    */
    PJ_DNS_TYPE_DNSKEY	= 48	/**< DNSSEC Key.			    */
} pj_dns_type;



/**
 * Standard DNS header, according to RFC 1035, which will be present in
 * both DNS query and DNS response. 
 *
 * Note that all values seen by application would be in
 * host by order. The library would convert them to network
 * byte order as necessary.
 */
typedef struct pj_dns_hdr
{
    pj_uint16_t  id;	    /**< Transaction ID.	    */
    pj_uint16_t  flags;	    /**< Flags.			    */
    pj_uint16_t  qdcount;   /**< Nb. of queries.	    */
    pj_uint16_t  anscount;  /**< Nb. of res records	    */
    pj_uint16_t  nscount;   /**< Nb. of NS records.	    */
    pj_uint16_t  arcount;   /**< Nb. of additional records  */
} pj_dns_hdr;

/** Create RCODE flag */
#define PJ_DNS_SET_RCODE(c)	((pj_uint16_t)((c) & 0x0F))

/** Create RA (Recursion Available) bit */
#define PJ_DNS_SET_RA(on)	((pj_uint16_t)((on) << 7))

/** Create RD (Recursion Desired) bit */
#define PJ_DNS_SET_RD(on)	((pj_uint16_t)((on) << 8))

/** Create TC (Truncated) bit */
#define PJ_DNS_SET_TC(on)	((pj_uint16_t)((on) << 9))

/** Create AA (Authoritative Answer) bit */
#define PJ_DNS_SET_AA(on)	((pj_uint16_t)((on) << 10))

/** Create four bits opcode */
#define PJ_DNS_SET_OPCODE(o)	((pj_uint16_t)((o)  << 11))

/** Create query/response bit */
#define PJ_DNS_SET_QR(on)	((pj_uint16_t)((on) << 15))


/** Get RCODE value */
#define PJ_DNS_GET_RCODE(val)	(((val) & PJ_DNS_SET_RCODE(0x0F)) >> 0)

/** Get RA bit */
#define PJ_DNS_GET_RA(val)	(((val) & PJ_DNS_SET_RA(1)) >> 7)

/** Get RD bit */
#define PJ_DNS_GET_RD(val)	(((val) & PJ_DNS_SET_RD(1)) >> 8)

/** Get TC bit */
#define PJ_DNS_GET_TC(val)	(((val) & PJ_DNS_SET_TC(1)) >> 9)

/** Get AA bit */
#define PJ_DNS_GET_AA(val)	(((val) & PJ_DNS_SET_AA(1)) >> 10)

/** Get OPCODE value */
#define PJ_DNS_GET_OPCODE(val)	(((val) & PJ_DNS_SET_OPCODE(0x0F)) >> 11)

/** Get QR bit */
#define PJ_DNS_GET_QR(val)	(((val) & PJ_DNS_SET_QR(1)) >> 15)


/** 
 * These constants describe DNS RCODEs. Application can fold these constants
 * into PJLIB pj_status_t namespace by calling #PJ_STATUS_FROM_DNS_RCODE()
 * macro.
 */
typedef enum pj_dns_rcode
{
    PJ_DNS_RCODE_FORMERR    = 1,    /**< Format error.			    */
    PJ_DNS_RCODE_SERVFAIL   = 2,    /**< Server failure.		    */
    PJ_DNS_RCODE_NXDOMAIN   = 3,    /**< Name Error.			    */
    PJ_DNS_RCODE_NOTIMPL    = 4,    /**< Not Implemented.		    */
    PJ_DNS_RCODE_REFUSED    = 5,    /**< Refused.			    */
    PJ_DNS_RCODE_YXDOMAIN   = 6,    /**< The name exists.		    */
    PJ_DNS_RCODE_YXRRSET    = 7,    /**< The RRset (name, type) exists.	    */
    PJ_DNS_RCODE_NXRRSET    = 8,    /**< The RRset (name, type) doesn't exist*/
    PJ_DNS_RCODE_NOTAUTH    = 9,    /**< Not authorized.		    */
    PJ_DNS_RCODE_NOTZONE    = 10    /**< The zone specified is not a zone.  */

} pj_dns_rcode;


/**
 * This structure describes a DNS query record.
 */
typedef struct pj_dns_parsed_query
{
    pj_str_t	name;	    /**< The domain in the query.		    */
    pj_uint16_t	type;	    /**< Type of the query (pj_dns_type)	    */
    pj_uint16_t	dnsclass;   /**< Network class (PJ_DNS_CLASS_IN=1)	    */
} pj_dns_parsed_query;


/**
 * This structure describes a Resource Record parsed from the DNS packet.
 * All integral values are in host byte order.
 */
typedef struct pj_dns_parsed_rr
{
    pj_str_t	 name;	    /**< The domain name which this rec pertains.   */
    pj_uint16_t	 type;	    /**< RR type code.				    */
    pj_uint16_t	 dnsclass;  /**< Class of data (PJ_DNS_CLASS_IN=1).	    */
    pj_uint32_t	 ttl;	    /**< Time to live.				    */
    pj_uint16_t	 rdlength;  /**< Resource data length.			    */
    void	*data;	    /**< Pointer to the raw resource data, only
				 when the type is not known. If it is known,
				 the data will be put in rdata below.	    */
    
    /** For resource types that are recognized/supported by this library,
     *  the parsed resource data will be placed in this rdata union.
     */
    union rdata
    {
	/** SRV Resource Data (PJ_DNS_TYPE_SRV, 33) */
	struct srv {
	    pj_uint16_t	prio;	/**< Target priority (lower is higher).	    */
	    pj_uint16_t weight;	/**< Weight/proportion			    */
	    pj_uint16_t port;	/**< Port number of the service		    */
	    pj_str_t	target;	/**< Target name.			    */
	} srv;

	/** CNAME Resource Data (PJ_DNS_TYPE_CNAME, 5) */
	struct cname {
	    pj_str_t	name;	/**< Primary canonical name for an alias.   */
	} cname;

	/** NS Resource Data (PJ_DNS_TYPE_NS, 2) */
	struct ns {
	    pj_str_t	name;	/**< Primary name server.		    */
	} ns;

	/** PTR Resource Data (PJ_DNS_TYPE_PTR, 12) */
	struct ptr {
	    pj_str_t	name;	/**< PTR name.				    */
	} ptr;

	/** A Resource Data (PJ_DNS_TYPE_A, 1) */
	struct a {
	    pj_in_addr	ip_addr;/**< IP host address string.		    */
	} a;

    } rdata;

} pj_dns_parsed_rr;


/**
 * This structure describes the parsed repersentation of the raw DNS packet.
 * Note that all integral values in the parsed packet are represented in
 * host byte order.
 */
typedef struct pj_dns_parsed_packet
{
    pj_dns_hdr		 hdr;	/**< Pointer to DNS hdr, in host byte order */
    pj_dns_parsed_query	*q;	/**< Array of DNS queries.		    */
    pj_dns_parsed_rr	*ans;	/**< Array of DNS RR answer.		    */
    pj_dns_parsed_rr	*ns;	/**< Array of NS record in the answer.	    */
    pj_dns_parsed_rr	*arr;	/**< Array of additional RR answer.	    */
} pj_dns_parsed_packet;


/**
 * Option flags to be specified when calling #pj_dns_packet_dup() function.
 * These flags can be combined with bitwise OR operation.
 */
enum pj_dns_dup_options
{
    PJ_DNS_NO_QD    = 1, /**< Do not duplicate the query section.	    */
    PJ_DNS_NO_ANS   = 2, /**< Do not duplicate the answer section.	    */
    PJ_DNS_NO_NS    = 4, /**< Do not duplicate the NS section.		    */
    PJ_DNS_NO_AR    = 8  /**< Do not duplicate the additional rec section   */
};


/**
 * Create DNS query packet to resolve the specified names. This function
 * can be used to build any types of DNS query, such as A record or DNS SRV
 * record.
 *
 * Application specifies the type of record and the name to be queried,
 * and the function will build the DNS query packet into the buffer
 * specified. Once the packet is successfully built, application can send
 * the packet via TCP or UDP connection.
 *
 * @param packet	The buffer to put the DNS query packet.
 * @param size		On input, it specifies the size of the buffer.
 *			On output, it will be filled with the actual size of
 *			the DNS query packet.
 * @param id		DNS query ID to associate DNS response with the
 *			query.
 * @param qtype		DNS type of record to be queried (see #pj_dns_type).
 * @param name		Name to be queried from the DNS server.
 *
 * @return		PJ_SUCCESS on success, or the appropriate error code.
 */
PJ_DECL(pj_status_t) pj_dns_make_query(void *packet,
				       unsigned *size,
				       pj_uint16_t id,
				       int qtype,
				       const pj_str_t *name);

/**
 * Parse raw DNS packet into parsed DNS packet structure. This function is
 * able to parse few DNS resource records such as A record, PTR record,
 * CNAME record, NS record, and SRV record.
 *
 * @param pool		Pool to allocate memory for the parsed packet.
 * @param packet	Pointer to the DNS packet (the TCP/UDP payload of 
 *			the raw packet).
 * @param size		The size of the DNS packet.
 * @param p_res		Pointer to store the resulting parsed packet.
 *
 * @return		PJ_SUCCESS on success, or the appropriate error code.
 */
PJ_DECL(pj_status_t) pj_dns_parse_packet(pj_pool_t *pool,
					 const void *packet,
					 unsigned size,
					 pj_dns_parsed_packet **p_res);

/**
 * Duplicate DNS packet.
 *
 * @param pool		The pool to allocate memory for the duplicated packet.
 * @param p		The DNS packet to be cloned.
 * @param options	Option flags, from pj_dns_dup_options.
 * @param p_dst		Pointer to store the cloned DNS packet.
 */
PJ_DECL(void) pj_dns_packet_dup(pj_pool_t *pool,
				const pj_dns_parsed_packet*p,
				unsigned options,
				pj_dns_parsed_packet **p_dst);


/**
 * Utility function to get the type name string of the specified DNS type.
 *
 * @param type		DNS type (see #pj_dns_type).
 *
 * @return		String name of the type (e.g. "A", "SRV", etc.).
 */
PJ_DECL(const char *) pj_dns_get_type_name(int type);


/**
 * Dump DNS packet to standard log.
 *
 * @param res		The DNS packet.
 */
PJ_DECL(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res);


/**
 * @}
 */

PJ_END_DECL


#endif	/* __PJLIB_UTIL_DNS_H__ */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合在线五月| 成人晚上爱看视频| 国产福利91精品一区二区三区| proumb性欧美在线观看| 91精品在线观看入口| 国产精品美女久久久久高潮| 丝袜国产日韩另类美女| 成人av在线看| 国产丝袜美腿一区二区三区| 丝袜国产日韩另类美女| 91色视频在线| 中文字幕第一页久久| 久久er99热精品一区二区| 欧美日韩一二三| 亚洲激情五月婷婷| 91网页版在线| 国产精品国产三级国产有无不卡| 国产中文字幕精品| 日韩欧美国产一二三区| 午夜不卡av免费| 色狠狠av一区二区三区| 亚洲人成在线播放网站岛国| 成人黄色在线看| 久久久久久亚洲综合影院红桃 | 欧美另类videos死尸| 国产精品污www在线观看| 精品在线免费观看| 日韩亚洲欧美一区二区三区| 亚洲va国产va欧美va观看| 一本大道久久a久久精品综合| 国产欧美视频在线观看| 狠狠色丁香婷婷综合久久片| 欧美成人猛片aaaaaaa| 日韩中文字幕不卡| 欧美一区二区啪啪| 免费日本视频一区| www亚洲一区| 国产高清精品网站| 国产精品久久久久久久久果冻传媒 | 91同城在线观看| 欧美激情在线一区二区| 成人国产视频在线观看| 中文字幕日本不卡| 色综合久久综合网97色综合| 一区二区三区自拍| 777奇米成人网| 国产一区二区三区最好精华液| 精品不卡在线视频| 国产福利不卡视频| 依依成人精品视频| 日韩欧美一区在线| 国产成人精品免费| 一区二区三区在线视频观看| 欧美伦理电影网| 国产激情精品久久久第一区二区 | 欧美精选一区二区| 中文字幕一区二区三中文字幕| 国产精品综合网| 久久精品一区二区三区不卡| 从欧美一区二区三区| 亚洲一区在线播放| 欧美r级在线观看| 99天天综合性| 日韩影视精彩在线| 国产精品伦一区| 日韩一级二级三级精品视频| 国产成人av电影免费在线观看| 亚洲综合精品自拍| 久久综合丝袜日本网| 91久久线看在观草草青青| 日本色综合中文字幕| 欧美高清一级片在线观看| 欧美午夜精品理论片a级按摩| 美日韩一区二区| 综合分类小说区另类春色亚洲小说欧美| 欧美久久久久久蜜桃| 国产成人av一区二区| 亚洲成av人片在www色猫咪| 日本一区二区三区电影| 欧美精品电影在线播放| 波多野结衣亚洲| 精品一区二区免费视频| 一区二区三区在线视频免费| 久久久综合精品| 日韩欧美国产精品一区| 在线视频欧美精品| 国产白丝网站精品污在线入口| 亚洲一区二区高清| 亚洲人成亚洲人成在线观看图片| 久久亚洲一区二区三区明星换脸 | 亚洲精品在线电影| 欧美日本乱大交xxxxx| 91视频免费看| 成人激情午夜影院| 国产一二精品视频| 日本欧美在线看| 亚洲国产一二三| 一区二区在线免费观看| 自拍偷拍亚洲激情| 国产精品美女一区二区三区| 久久精品欧美日韩| 精品剧情v国产在线观看在线| 欧美日韩成人在线| 欧美自拍丝袜亚洲| 在线视频你懂得一区| 色哟哟一区二区在线观看| 成人av电影在线| 成人免费视频免费观看| 国产成人免费av在线| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美一级黄色大片| 宅男噜噜噜66一区二区66| 欧美日韩一卡二卡| 678五月天丁香亚洲综合网| 欧美精品一卡两卡| 欧美日韩国产在线播放网站| 欧美在线制服丝袜| 欧美性一级生活| 欧美性xxxxxx少妇| 欧美日韩国产小视频| 欧美日韩国产一级| 日韩一区国产二区欧美三区| 日韩欧美国产精品| 国产午夜亚洲精品羞羞网站| 国产欧美一区二区精品婷婷| 国产精品你懂的在线欣赏| 国产精品国产三级国产专播品爱网 | 一区二区三区四区亚洲| 亚洲精品成人精品456| 亚洲一区二区三区在线播放| 午夜精品免费在线观看| 五月婷婷久久丁香| 久久成人羞羞网站| 成人中文字幕合集| 欧美系列在线观看| 精品99一区二区| 国产精品久久久久久久久免费丝袜 | 欧美aⅴ一区二区三区视频| 青青国产91久久久久久| 精品一区二区三区不卡| 99久久综合精品| 欧美日韩免费视频| 欧美成人女星排名| 亚洲人精品一区| 麻豆精品视频在线观看免费| 成人精品视频一区二区三区| 在线视频综合导航| 久久综合久久久久88| 亚洲精品免费看| 精品一区二区久久久| 色婷婷综合久久久久中文| 日韩一区二区免费在线电影| 欧美激情综合五月色丁香小说| 亚洲影视资源网| 国产一区二区日韩精品| 欧美性高清videossexo| 国产视频一区二区三区在线观看| 亚洲欧美日韩中文播放| 精品一区二区久久| 欧美午夜精品一区二区三区 | 成人午夜av电影| 欧美日韩国产小视频| 国产精品免费网站在线观看| 日韩av一区二| av影院午夜一区| www欧美成人18+| 免费成人av在线播放| 日本丶国产丶欧美色综合| 久久久久久久久久电影| 日日夜夜精品视频免费| 97国产一区二区| 久久久久久麻豆| 久久精品国产亚洲一区二区三区 | 成人av免费网站| 久久欧美中文字幕| 日日噜噜夜夜狠狠视频欧美人| 菠萝蜜视频在线观看一区| 欧美tk丨vk视频| 日韩精品一二区| 欧美又粗又大又爽| 亚洲激情男女视频| av电影天堂一区二区在线| 国产日韩精品一区二区浪潮av| 蜜桃91丨九色丨蝌蚪91桃色| 欧美私人免费视频| 亚洲欧美色综合| 99re视频精品| 亚洲同性gay激情无套| youjizz国产精品| 国产欧美一区二区三区沐欲| 麻豆精品新av中文字幕| 日韩欧美精品三级| 久久国产人妖系列| 欧美一区二区人人喊爽| 欧美aⅴ一区二区三区视频| 欧美一区二区女人| 久久国产精品99精品国产 | 综合久久一区二区三区| 成人av动漫网站| 亚洲视频你懂的|