message.c File Reference

#include <config.h>
#include <ctype.h>
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/dnssec.h>
#include <dns/keyvalues.h>
#include <dns/log.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/opcode.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/result.h>
#include <dns/tsig.h>
#include <dns/ttl.h>
#include <dns/view.h>

Go to the source code of this file.

Data Structures

struct  dns_msgblock
 "helper" type, which consists of a block of some type, and is linkable. For it to work, sizeof(dns_msgblock_t) must be a multiple of the pointer size, or the allocated elements will not be aligned correctly. More...

Defines

#define DNS_MESSAGE_OPCODE_MASK   0x7800U
#define DNS_MESSAGE_OPCODE_SHIFT   11
#define DNS_MESSAGE_RCODE_MASK   0x000fU
#define DNS_MESSAGE_FLAG_MASK   0x8ff0U
#define DNS_MESSAGE_EDNSRCODE_MASK   0xff000000U
#define DNS_MESSAGE_EDNSRCODE_SHIFT   24
#define DNS_MESSAGE_EDNSVERSION_MASK   0x00ff0000U
#define DNS_MESSAGE_EDNSVERSION_SHIFT   16
#define VALID_NAMED_SECTION(s)
#define VALID_SECTION(s)
#define ADD_STRING(b, s)
#define VALID_PSEUDOSECTION(s)
#define OPTOUT(x)   (((x)->attributes & DNS_RDATASETATTR_OPTOUT) != 0)
#define SCRATCHPAD_SIZE   512
 This is the size of each individual scratchpad buffer, and the numbers of various block allocations used within the server. XXXMLG These should come from a config setting.
#define NAME_COUNT   8
#define OFFSET_COUNT   4
#define RDATA_COUNT   8
#define RDATALIST_COUNT   8
#define RDATASET_COUNT   RDATALIST_COUNT
#define msgblock_get(block, type)   ((type *)msgblock_internalget(block, sizeof(type)))
#define DO_FORMERR

Functions

static dns_msgblock_tmsgblock_allocate (isc_mem_t *, unsigned int, unsigned int)
static void * msgblock_internalget (dns_msgblock_t *, unsigned int)
static void msgblock_reset (dns_msgblock_t *)
static void msgblock_free (isc_mem_t *, dns_msgblock_t *, unsigned int)
static void logfmtpacket (dns_message_t *message, const char *description, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, const dns_master_style_t *style, int level, isc_mem_t *mctx)
static isc_result_t newbuffer (dns_message_t *msg, unsigned int size)
static isc_buffer_tcurrentbuffer (dns_message_t *msg)
static void releaserdata (dns_message_t *msg, dns_rdata_t *rdata)
static dns_rdata_tnewrdata (dns_message_t *msg)
static void releaserdatalist (dns_message_t *msg, dns_rdatalist_t *rdatalist)
static dns_rdatalist_tnewrdatalist (dns_message_t *msg)
static dns_offsets_tnewoffsets (dns_message_t *msg)
static void msginitheader (dns_message_t *m)
static void msginitprivate (dns_message_t *m)
static void msginittsig (dns_message_t *m)
static void msginit (dns_message_t *m)
static void msgresetnames (dns_message_t *msg, unsigned int first_section)
static void msgresetopt (dns_message_t *msg)
static void msgresetsigs (dns_message_t *msg, isc_boolean_t replying)
static void msgreset (dns_message_t *msg, isc_boolean_t everything)
static unsigned int spacefortsig (dns_tsigkey_t *key, int otherlen)
isc_result_t dns_message_create (isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
 Create msg structure.
void dns_message_reset (dns_message_t *msg, unsigned int intent)
 Reset a message structure to default state. All internal lists are freed or reset to a default state as well. This is simply a more efficient way to call dns_message_destroy() followed by dns_message_allocate(), since it avoid many memory allocations.
void dns_message_destroy (dns_message_t **msgp)
 Destroy all state in the message.
static isc_result_t findname (dns_name_t **foundname, dns_name_t *target, dns_namelist_t *section)
isc_result_t dns_message_find (dns_name_t *name, dns_rdataclass_t rdclass, dns_rdatatype_t type, dns_rdatatype_t covers, dns_rdataset_t **rdataset)
 Search the name for the specified rdclass and type. If it is found, *rdataset is filled in with a pointer to that rdataset.
isc_result_t dns_message_findtype (dns_name_t *name, dns_rdatatype_t type, dns_rdatatype_t covers, dns_rdataset_t **rdataset)
 Search the name for the specified type. If it is found, *rdataset is filled in with a pointer to that rdataset.
static isc_result_t getname (dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
static isc_result_t getrdata (isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, dns_rdataclass_t rdclass, dns_rdatatype_t rdtype, unsigned int rdatalen, dns_rdata_t *rdata)
static isc_result_t getquestions (isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, unsigned int options)
static isc_boolean_t update (dns_section_t section, dns_rdataclass_t rdclass)
static isc_result_t getsection (isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, dns_section_t sectionid, unsigned int options)
isc_result_t dns_message_parse (dns_message_t *msg, isc_buffer_t *source, unsigned int options)
 Parse raw wire data in 'source' as a DNS message.
isc_result_t dns_message_renderbegin (dns_message_t *msg, dns_compress_t *cctx, isc_buffer_t *buffer)
 Begin rendering on a message. Only one call can be made to this function per message.
isc_result_t dns_message_renderchangebuffer (dns_message_t *msg, isc_buffer_t *buffer)
 Reset the buffer. This can be used after growing the old buffer on a ISC_R_NOSPACE return from most of the render functions.
void dns_message_renderrelease (dns_message_t *msg, unsigned int space)
 XXXMLG should use size_t rather than unsigned int once the buffer API is cleaned up.
isc_result_t dns_message_renderreserve (dns_message_t *msg, unsigned int space)
 XXXMLG should use size_t rather than unsigned int once the buffer API is cleaned up.
static isc_boolean_t wrong_priority (dns_rdataset_t *rds, int pass, dns_rdatatype_t preferred_glue)
isc_result_t dns_message_rendersection (dns_message_t *msg, dns_section_t sectionid, unsigned int options)
 Render all names, rdatalists, etc from the given section at the specified priority or higher.
void dns_message_renderheader (dns_message_t *msg, isc_buffer_t *target)
 Render the message header. This is implicitly called by dns_message_renderend().
isc_result_t dns_message_renderend (dns_message_t *msg)
 Finish rendering to the buffer. Note that more data can be in the 'msg' structure. Destroying the structure will free this, or in a multi- part EDNS1 message this data can be rendered to another buffer later.
void dns_message_renderreset (dns_message_t *msg)
 Reset the message so that it may be rendered again.
isc_result_t dns_message_firstname (dns_message_t *msg, dns_section_t section)
 Set internal per-section name pointer to the beginning of the section.
isc_result_t dns_message_nextname (dns_message_t *msg, dns_section_t section)
 Sets the internal per-section name pointer to point to the next name in that section.
void dns_message_currentname (dns_message_t *msg, dns_section_t section, dns_name_t **name)
 Sets 'name' to point to the name where the per-section internal name pointer is currently set.
isc_result_t dns_message_findname (dns_message_t *msg, dns_section_t section, dns_name_t *target, dns_rdatatype_t type, dns_rdatatype_t covers, dns_name_t **name, dns_rdataset_t **rdataset)
 Search for a name in the specified section. If it is found, *name is set to point to the name, and *rdataset is set to point to the found rdataset (if type is specified as other than dns_rdatatype_any).
void dns_message_movename (dns_message_t *msg, dns_name_t *name, dns_section_t fromsection, dns_section_t tosection)
 Move a name from one section to another.
void dns_message_addname (dns_message_t *msg, dns_name_t *name, dns_section_t section)
 Adds the name to the given section.
void dns_message_removename (dns_message_t *msg, dns_name_t *name, dns_section_t section)
 Remove a existing name from a given section.
isc_result_t dns_message_gettempname (dns_message_t *msg, dns_name_t **item)
 Return a name that can be used for any temporary purpose, including inserting into the message's linked lists. The name must be returned to the message code using dns_message_puttempname() or inserted into one of the message's sections before the message is destroyed.
isc_result_t dns_message_gettempoffsets (dns_message_t *msg, dns_offsets_t **item)
 Return an offsets array that can be used for any temporary purpose, such as attaching to a temporary name. The offsets will be freed when the message is destroyed or reset.
isc_result_t dns_message_gettemprdata (dns_message_t *msg, dns_rdata_t **item)
 Return a rdata that can be used for any temporary purpose, including inserting into the message's linked lists. The rdata will be freed when the message is destroyed or reset.
isc_result_t dns_message_gettemprdataset (dns_message_t *msg, dns_rdataset_t **item)
 Return a rdataset that can be used for any temporary purpose, including inserting into the message's linked lists. The name must be returned to the message code using dns_message_puttempname() or inserted into one of the message's sections before the message is destroyed.
isc_result_t dns_message_gettemprdatalist (dns_message_t *msg, dns_rdatalist_t **item)
 Return a rdatalist that can be used for any temporary purpose, including inserting into the message's linked lists. The rdatalist will be destroyed when the message is destroyed or reset.
void dns_message_puttempname (dns_message_t *msg, dns_name_t **item)
 Return a borrowed name to the message's name free list.
void dns_message_puttemprdata (dns_message_t *msg, dns_rdata_t **item)
 Return a borrowed rdata to the message's rdata free list.
void dns_message_puttemprdataset (dns_message_t *msg, dns_rdataset_t **item)
 Return a borrowed rdataset to the message's rdataset free list.
void dns_message_puttemprdatalist (dns_message_t *msg, dns_rdatalist_t **item)
 Return a borrowed rdatalist to the message's rdatalist free list.
isc_result_t dns_message_peekheader (isc_buffer_t *source, dns_messageid_t *idp, unsigned int *flagsp)
 Assume the remaining region of "source" is a DNS message. Peek into it and fill in "*idp" with the message id, and "*flagsp" with the flags.
isc_result_t dns_message_reply (dns_message_t *msg, isc_boolean_t want_question_section)
 Start formatting a reply to the query in 'msg'.
dns_rdataset_tdns_message_getopt (dns_message_t *msg)
 Get the OPT record for 'msg'.
isc_result_t dns_message_setopt (dns_message_t *msg, dns_rdataset_t *opt)
 Set the OPT record for 'msg'.
dns_rdataset_tdns_message_gettsig (dns_message_t *msg, dns_name_t **owner)
 Get the TSIG record and owner for 'msg'.
isc_result_t dns_message_settsigkey (dns_message_t *msg, dns_tsigkey_t *key)
 Set the tsig key for 'msg'. This is only necessary for when rendering a query or parsing a response. The key (if non-NULL) is attached to, and will be detached when the message is destroyed.
dns_tsigkey_tdns_message_gettsigkey (dns_message_t *msg)
 Gets the tsig key for 'msg'.
isc_result_t dns_message_setquerytsig (dns_message_t *msg, isc_buffer_t *querytsig)
 Indicates that 'querytsig' is the TSIG from the signed query for which 'msg' is the response. This is also used for chained TSIGs in TCP responses.
isc_result_t dns_message_getquerytsig (dns_message_t *msg, isc_mem_t *mctx, isc_buffer_t **querytsig)
 Gets the tsig from the TSIG from the signed query 'msg'. This is also used for chained TSIGs in TCP responses. Unlike dns_message_gettsig, this makes a copy of the data, so can be used if the message is destroyed.
dns_rdataset_tdns_message_getsig0 (dns_message_t *msg, dns_name_t **owner)
 Get the SIG(0) record and owner for 'msg'.
isc_result_t dns_message_setsig0key (dns_message_t *msg, dst_key_t *key)
 Set the SIG(0) key for 'msg'.
dst_key_tdns_message_getsig0key (dns_message_t *msg)
 Gets the SIG(0) key for 'msg'.
void dns_message_takebuffer (dns_message_t *msg, isc_buffer_t **buffer)
 Give the *buffer to the message code to clean up when it is no longer needed. This is usually when the message is reset or destroyed.
isc_result_t dns_message_signer (dns_message_t *msg, dns_name_t *signer)
 If this message was signed, return the identity of the signer. Unless ISC_R_NOTFOUND is returned, signer will reflect the name of the key that signed the message.
void dns_message_resetsig (dns_message_t *msg)
 Reset the signature state.
isc_result_t dns_message_rechecksig (dns_message_t *msg, dns_view_t *view)
 Reset the signature state and then if the message was signed, verify the message.
isc_result_t dns_message_checksig (dns_message_t *msg, dns_view_t *view)
 If this message was signed, verify the signature.
isc_result_t dns_message_sectiontotext (dns_message_t *msg, dns_section_t section, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target)
static isc_result_t render_ecs (isc_buffer_t *optbuf, isc_buffer_t *target)
isc_result_t dns_message_pseudosectiontotext (dns_message_t *msg, dns_pseudosection_t section, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target)
 Convert section 'section' or 'pseudosection' of message 'msg' to a cleartext representation.
isc_result_t dns_message_totext (dns_message_t *msg, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target)
 Convert all sections of message 'msg' to a cleartext representation.
isc_region_tdns_message_getrawmessage (dns_message_t *msg)
 Retrieve the raw message in compressed wire format. The message must have been successfully parsed for it to have been saved.
void dns_message_setsortorder (dns_message_t *msg, dns_rdatasetorderfunc_t order, const void *order_arg)
 Define the order in which RR sets get rendered by dns_message_rendersection() to be the ascending order defined by the integer value returned by 'order' when given each RR and 'arg' as arguments. If 'order' and 'order_arg' are NULL, a default order is used.
void dns_message_settimeadjust (dns_message_t *msg, int timeadjust)
 Adjust the time used to sign/verify a message by timeadjust. Currently only TSIG.
int dns_message_gettimeadjust (dns_message_t *msg)
 Return the current time adjustment.
isc_result_t dns_opcode_totext (dns_opcode_t opcode, isc_buffer_t *target)
 Put a textual representation of error 'opcode' into 'target'.
void dns_message_logpacket (dns_message_t *message, const char *description, isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_mem_t *mctx)
void dns_message_logpacket2 (dns_message_t *message, const char *description, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_mem_t *mctx)
void dns_message_logfmtpacket (dns_message_t *message, const char *description, isc_logcategory_t *category, isc_logmodule_t *module, const dns_master_style_t *style, int level, isc_mem_t *mctx)
void dns_message_logfmtpacket2 (dns_message_t *message, const char *description, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, const dns_master_style_t *style, int level, isc_mem_t *mctx)
 Log 'message' at the specified logging parameters.
isc_result_t dns_message_buildopt (dns_message_t *message, dns_rdataset_t **rdatasetp, unsigned int version, isc_uint16_t udpsize, unsigned int flags, dns_ednsopt_t *ednsopts, size_t count)
 Built a opt record.

Variables

static const char * sectiontext []
 Text representation of the different items, for message_totext functions.
static const char * updsectiontext []
static const char * opcodetext []
static const char * rcodetext []


Detailed Description

Definition in file message.c.


Define Documentation

#define DNS_MESSAGE_OPCODE_MASK   0x7800U

Definition at line 77 of file message.c.

Referenced by dns_message_parse(), and dns_message_renderheader().

#define DNS_MESSAGE_OPCODE_SHIFT   11

Definition at line 78 of file message.c.

Referenced by dns_message_parse(), and dns_message_renderheader().

#define DNS_MESSAGE_RCODE_MASK   0x000fU

Definition at line 79 of file message.c.

Referenced by dns_message_parse(), dns_message_renderend(), and dns_message_renderheader().

#define DNS_MESSAGE_FLAG_MASK   0x8ff0U

Definition at line 80 of file message.c.

Referenced by dns_message_parse(), dns_message_peekheader(), and dns_message_renderheader().

#define DNS_MESSAGE_EDNSRCODE_MASK   0xff000000U

Definition at line 81 of file message.c.

Referenced by dns_message_renderend(), and getsection().

#define DNS_MESSAGE_EDNSRCODE_SHIFT   24

Definition at line 82 of file message.c.

#define DNS_MESSAGE_EDNSVERSION_MASK   0x00ff0000U

Definition at line 83 of file message.c.

#define DNS_MESSAGE_EDNSVERSION_SHIFT   16

Definition at line 84 of file message.c.

#define VALID_NAMED_SECTION ( s   ) 

Value:

(((s) > DNS_SECTION_ANY) \
                                 && ((s) < DNS_SECTION_MAX))

Definition at line 86 of file message.c.

Referenced by dns_message_addname(), dns_message_currentname(), dns_message_firstname(), dns_message_movename(), dns_message_nextname(), dns_message_removename(), and dns_message_rendersection().

#define VALID_SECTION ( s   ) 

Value:

(((s) >= DNS_SECTION_ANY) \
                                 && ((s) < DNS_SECTION_MAX))

Definition at line 88 of file message.c.

Referenced by dns_message_findname(), and dns_message_sectiontotext().

#define ADD_STRING ( b,
s   ) 

Value:

{if (strlen(s) >= \
                                   isc_buffer_availablelength(b)) \
                                       return(ISC_R_NOSPACE); else \
                                       isc_buffer_putstr(b, s);}

Definition at line 90 of file message.c.

Referenced by dns_message_pseudosectiontotext(), dns_message_sectiontotext(), dns_message_totext(), render_ecs(), and say_message().

#define VALID_PSEUDOSECTION ( s   ) 

Value:

Definition at line 94 of file message.c.

Referenced by dns_message_pseudosectiontotext().

#define OPTOUT (  )     (((x)->attributes & DNS_RDATASETATTR_OPTOUT) != 0)

Definition at line 97 of file message.c.

Referenced by assignwork(), bind_rdataset(), dns_message_rendersection(), dns_nsec3_addnsec3(), main(), nsec3ify(), and set_nsec3params().

#define SCRATCHPAD_SIZE   512

This is the size of each individual scratchpad buffer, and the numbers of various block allocations used within the server. XXXMLG These should come from a config setting.

Definition at line 104 of file message.c.

Referenced by dns_message_create(), getname(), and getrdata().

#define NAME_COUNT   8

Definition at line 105 of file message.c.

Referenced by dns_message_create().

#define OFFSET_COUNT   4

Definition at line 106 of file message.c.

Referenced by newoffsets().

#define RDATA_COUNT   8

Definition at line 107 of file message.c.

Referenced by newrdata().

#define RDATALIST_COUNT   8

Definition at line 108 of file message.c.

Referenced by newrdatalist().

#define RDATASET_COUNT   RDATALIST_COUNT

Definition at line 109 of file message.c.

#define msgblock_get ( block,
type   )     ((type *)msgblock_internalget(block, sizeof(type)))

Definition at line 183 of file message.c.

Referenced by newoffsets(), newrdata(), and newrdatalist().

#define DO_FORMERR

Value:

do {                                            \
                if (best_effort)                        \
                        seen_problem = ISC_TRUE;        \
                else {                                  \
                        result = DNS_R_FORMERR;         \
                        goto cleanup;                   \
                }                                       \
        } while (0)

Definition at line 996 of file message.c.

Referenced by getquestions(), and getsection().


Function Documentation

static dns_msgblock_t * msgblock_allocate ( isc_mem_t mctx,
unsigned int  sizeof_type,
unsigned int  count 
) [inline, static]

Definition at line 206 of file message.c.

References block, dns_msgblock::count, ISC_LINK_INIT, isc_mem_get, and dns_msgblock::remaining.

Referenced by newoffsets(), newrdata(), and newrdatalist().

static void * msgblock_internalget ( dns_msgblock_t block,
unsigned int  sizeof_type 
) [inline, static]

Definition at line 231 of file message.c.

References dns_msgblock::remaining.

static void msgblock_reset ( dns_msgblock_t block  )  [inline, static]

Definition at line 247 of file message.c.

References dns_msgblock::count, and dns_msgblock::remaining.

Referenced by msgreset().

static void msgblock_free ( isc_mem_t mctx,
dns_msgblock_t block,
unsigned int  sizeof_type 
) [inline, static]

Definition at line 255 of file message.c.

References dns_msgblock::count, and isc_mem_put.

Referenced by msgreset().

static void logfmtpacket ( dns_message_t message,
const char *  description,
isc_sockaddr_t address,
isc_logcategory_t category,
isc_logmodule_t module,
const dns_master_style_t style,
int  level,
isc_mem_t mctx 
) [static]

Definition at line 3608 of file message.c.

References buffer, dns_lctx, dns_message_totext(), isc_buffer_init, isc_buffer_usedlength, isc_log_wouldlog(), isc_log_write(), isc_mem_get, isc_mem_put, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_sockaddr_format(), and ISC_SOCKADDR_FORMATSIZE.

Referenced by dns_message_logfmtpacket(), dns_message_logfmtpacket2(), dns_message_logpacket(), and dns_message_logpacket2().

static isc_result_t newbuffer ( dns_message_t msg,
unsigned int  size 
) [inline, static]

Definition at line 270 of file message.c.

References isc_buffer_allocate(), ISC_LIST_APPEND, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_message::mctx, and dns_message::scratchpad.

Referenced by getname(), and getrdata().

static isc_buffer_t* currentbuffer ( dns_message_t msg  )  [inline, static]

Definition at line 284 of file message.c.

References INSIST, ISC_LIST_TAIL, and dns_message::scratchpad.

Referenced by getname(), and getrdata().

static void releaserdata ( dns_message_t msg,
dns_rdata_t rdata 
) [inline, static]

Definition at line 294 of file message.c.

References ISC_LIST_PREPEND.

Referenced by dns_message_puttemprdata().

static dns_rdata_t* newrdata ( dns_message_t msg  )  [inline, static]

Definition at line 299 of file message.c.

References dns_rdata_init(), ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_TAIL, ISC_LIST_UNLINK, dns_message::mctx, msgblock_allocate(), msgblock_get, and RDATA_COUNT.

Referenced by add_rdata_to_list(), copy_name(), dns_message_gettemprdata(), and getsection().

static void releaserdatalist ( dns_message_t msg,
dns_rdatalist_t rdatalist 
) [inline, static]

Definition at line 327 of file message.c.

References ISC_LIST_PREPEND.

Referenced by dns_message_puttemprdatalist().

static dns_rdatalist_t* newrdatalist ( dns_message_t msg  )  [inline, static]

Definition at line 332 of file message.c.

References dns_rdatalist_init(), ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_TAIL, ISC_LIST_UNLINK, dns_message::mctx, msgblock_allocate(), msgblock_get, and RDATALIST_COUNT.

Referenced by dns_message_gettemprdatalist(), getquestions(), and getsection().

static dns_offsets_t* newoffsets ( dns_message_t msg  )  [inline, static]

Definition at line 363 of file message.c.

References ISC_LIST_APPEND, ISC_LIST_TAIL, dns_message::mctx, msgblock_allocate(), msgblock_get, and OFFSET_COUNT.

Referenced by dns_message_gettempoffsets(), getquestions(), and getsection().

static void msginitheader ( dns_message_t m  )  [inline, static]

Definition at line 385 of file message.c.

References dns_message::flags, dns_message::id, dns_message::opcode, dns_message::rcode, and dns_message::rdclass.

Referenced by msginit().

static void msginitprivate ( dns_message_t m  )  [inline, static]

Definition at line 394 of file message.c.

References dns_message::buffer, dns_message::counts, dns_message::cursors, DNS_SECTION_ANY, DNS_SECTION_MAX, dns_message::opt, dns_message::opt_reserved, dns_message::reserved, dns_message::sig0, dns_message::sig0name, dns_message::sig_reserved, dns_message::state, dns_message::tsig, and dns_message::tsigname.

Referenced by dns_message_reply(), and msginit().

static void msginittsig ( dns_message_t m  )  [inline, static]

Definition at line 414 of file message.c.

References dns_rcode_noerror, dns_message::querytsigstatus, dns_message::sig0key, dns_message::sig0status, dns_message::sigstart, dns_message::timeadjust, dns_message::tsigctx, dns_message::tsigkey, and dns_message::tsigstatus.

Referenced by msginit().

static void msginit ( dns_message_t m  )  [inline, static]

Definition at line 430 of file message.c.

References isc_region::base, dns_message::free_query, dns_message::free_saved, dns_message::header_ok, isc_region::length, msginitheader(), msginitprivate(), msginittsig(), dns_message::order, dns_message::order_arg, dns_message::query, dns_message::querytsig, dns_message::question_ok, dns_message::saved, dns_message::sitbad, dns_message::sitok, dns_message::tcp_continuation, dns_message::verified_sig, and dns_message::verify_attempted.

Referenced by dns_message_create(), and msgreset().

static void msgresetnames ( dns_message_t msg,
unsigned int  first_section 
) [inline, static]

Definition at line 453 of file message.c.

References dns_name_dynamic(), dns_name_free(), dns_rdataset_disassociate(), dns_rdataset_isassociated(), DNS_SECTION_MAX, INSIST, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mempool_put, dns_message::mctx, name, dns_message::namepool, dns_message::rdspool, and dns_message::sections.

Referenced by dns_message_renderend(), dns_message_reply(), and msgreset().

static void msgresetopt ( dns_message_t msg  )  [static]

Definition at line 486 of file message.c.

References dns_message_renderrelease(), dns_rdataset_disassociate(), dns_rdataset_isassociated(), INSIST, isc_mempool_put, dns_message::opt, dns_message::opt_reserved, dns_message::rdspool, dns_message::sitbad, and dns_message::sitok.

Referenced by dns_message_reply(), dns_message_setopt(), and msgreset().

static void msgresetsigs ( dns_message_t msg,
isc_boolean_t  replying 
) [static]

Definition at line 503 of file message.c.

References dns_message_renderrelease(), dns_name_dynamic(), dns_name_free(), dns_rdataset_disassociate(), dns_rdataset_isassociated(), INSIST, isc_mempool_put, dns_message::mctx, dns_message::namepool, dns_message::querytsig, dns_message::rdspool, dns_message::sig0, dns_message::sig0name, dns_message::sig_reserved, dns_message::tsig, and dns_message::tsigname.

Referenced by dns_message_reply(), and msgreset().

static void msgreset ( dns_message_t msg,
isc_boolean_t  everything 
) [static]

Definition at line 551 of file message.c.

References isc_region::base, dns_message::cleanup, dns_tsigkey_detach(), dst_context_destroy(), ENSURE, dns_message::free_query, dns_message::free_saved, INSIST, isc_buffer_clear, isc_buffer_free(), ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mem_put, isc_mempool_getallocated(), isc_region::length, dns_message::mctx, msgblock_free(), msgblock_reset(), msginit(), msgresetnames(), msgresetopt(), msgresetsigs(), dns_message::namepool, dns_message::query, dns_message::rdspool, dns_message::saved, dns_message::scratchpad, dns_message::tsigctx, and dns_message::tsigkey.

Referenced by dns_message_destroy(), and dns_message_reset().

static unsigned int spacefortsig ( dns_tsigkey_t key,
int  otherlen 
) [static]

Definition at line 680 of file message.c.

References dns_tsigkey::algorithm, dns_name_toregion(), dst_key_sigsize(), ISC_R_SUCCESS, dns_tsigkey::key, isc_region::length, dns_tsigkey::name, r1, and r2.

Referenced by dns_message_reply(), and dns_message_settsigkey().

isc_result_t dns_message_create ( isc_mem_t mctx,
unsigned int  intent,
dns_message_t **  msgp 
)

Create msg structure.

This function will allocate some internal blocks of memory that are expected to be needed for parsing or rendering nearly any type of message.

Requires:

Ensures: Returns:

Definition at line 719 of file message.c.

References dns_message::cctx, cleanup(), dns_message::cleanup, DNS_MESSAGE_INTENTPARSE, DNS_MESSAGE_INTENTRENDER, DNS_MESSAGE_MAGIC, DNS_SECTION_MAX, dns_message::from_to_wire, isc_buffer_allocate(), isc_buffer_free(), ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_UNLINK, isc_mem_attach(), isc_mem_get, isc_mem_putanddetach, isc_mempool_create(), isc_mempool_destroy(), isc_mempool_setfreemax(), isc_mempool_setname(), ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_message::magic, dns_message::mctx, msginit(), NAME_COUNT, dns_message::namepool, dns_message::rdspool, REQUIRE, dns_message::scratchpad, SCRATCHPAD_SIZE, and dns_message::sections.

Referenced by client_create(), create_query(), dns_client_startupdate(), fctx_create(), forward_callback(), notify_createmessage(), notify_done(), receive_soa(), recv_done(), recvsoa(), refresh_callback(), request_soa(), reset_system(), sendstream(), setup_lookup(), start_update(), stub_callback(), update_completed(), update_done(), xfrin_recv_done(), and xfrin_send_request().

void dns_message_reset ( dns_message_t msg,
unsigned int  intent 
)

Reset a message structure to default state. All internal lists are freed or reset to a default state as well. This is simply a more efficient way to call dns_message_destroy() followed by dns_message_allocate(), since it avoid many memory allocations.

If any data loanouts (buffers, names, rdatas, etc) were requested, the caller must no longer use them after this call.

The intended next use of the message will be 'intent'.

Requires:

Definition at line 809 of file message.c.

References DNS_MESSAGE_INTENTPARSE, DNS_MESSAGE_INTENTRENDER, DNS_MESSAGE_VALID, dns_message::from_to_wire, ISC_FALSE, msgreset(), and REQUIRE.

Referenced by fctx_query(), ns_client_endrequest(), reset_system(), and resquery_send().

void dns_message_destroy ( dns_message_t **  msgp  ) 

Destroy all state in the message.

Requires:

Ensures:

Definition at line 819 of file message.c.

References DNS_MESSAGE_VALID, isc_mem_putanddetach, isc_mempool_destroy(), ISC_TRUE, dns_message::magic, dns_message::mctx, msgreset(), dns_message::namepool, dns_message::rdspool, and REQUIRE.

Referenced by cleanup(), client_create(), create_query(), destroy_libs(), destroy_lookup(), dns_client_startupdate(), doshutdown(), exit_check(), fctx_create(), fctx_destroy(), flush_lookup_list(), forward_callback(), forward_done(), notify_createmessage(), notify_done(), notify_send_toaddr(), ns_query(), receive_soa(), recv_done(), recvsoa(), refresh_callback(), request_soa(), sendstream(), soa_query(), start_update(), stub_callback(), update_done(), update_sendevent(), xfrin_recv_done(), and xfrin_send_request().

static isc_result_t findname ( dns_name_t **  foundname,
dns_name_t target,
dns_namelist_t *  section 
) [static]

Definition at line 836 of file message.c.

References dns_name_equal(), ISC_LIST_PREV, ISC_LIST_TAIL, ISC_R_NOTFOUND, and ISC_R_SUCCESS.

Referenced by dns_message_findname(), fctx_getaddresses(), getquestions(), and getsection().

isc_result_t dns_message_find ( dns_name_t name,
dns_rdataclass_t  rdclass,
dns_rdatatype_t  type,
dns_rdatatype_t  covers,
dns_rdataset_t **  rdataset 
)

Search the name for the specified rdclass and type. If it is found, *rdataset is filled in with a pointer to that rdataset.

Requires:

Returns:

Definition at line 855 of file message.c.

References dns_rdataset::covers, ISC_LIST_PREV, ISC_LIST_TAIL, ISC_R_NOTFOUND, ISC_R_SUCCESS, dns_rdataset::rdclass, REQUIRE, and dns_rdataset::type.

Referenced by getquestions(), and getsection().

isc_result_t dns_message_findtype ( dns_name_t name,
dns_rdatatype_t  type,
dns_rdatatype_t  covers,
dns_rdataset_t **  rdataset 
)

Search the name for the specified type. If it is found, *rdataset is filled in with a pointer to that rdataset.

Requires:

Returns:

Definition at line 880 of file message.c.

References dns_rdataset::covers, ISC_LIST_PREV, ISC_LIST_TAIL, ISC_R_NOTFOUND, ISC_R_SUCCESS, REQUIRE, and dns_rdataset::type.

Referenced by check_section(), dns_message_findname(), dns_tkey_processdhresponse(), find_tkey(), followup_lookup(), process_dhtkey(), query_addds(), receive_soa(), and recvsoa().

static isc_result_t getname ( dns_name_t name,
isc_buffer_t source,
dns_message_t msg,
dns_decompress_t dctx 
) [static]

Definition at line 907 of file message.c.

References currentbuffer(), dns_name_fromwire(), dns_name_reset(), INSIST, ISC_FALSE, ISC_R_NOSPACE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, newbuffer(), SCRATCHPAD_SIZE, and tries.

Referenced by getquestions(), and getsection().

static isc_result_t getrdata ( isc_buffer_t source,
dns_message_t msg,
dns_decompress_t dctx,
dns_rdataclass_t  rdclass,
dns_rdatatype_t  rdtype,
unsigned int  rdatalen,
dns_rdata_t rdata 
) [static]

Definition at line 944 of file message.c.

References currentbuffer(), dns_rdata_fromwire(), INSIST, isc_buffer_setactive, ISC_R_NOSPACE, ISC_R_SUCCESS, newbuffer(), SCRATCHPAD_SIZE, and tries.

Referenced by getsection().

static isc_result_t getquestions ( isc_buffer_t source,
dns_message_t msg,
dns_decompress_t dctx,
unsigned int  options 
) [static]

Definition at line 1007 of file message.c.

References dns_rdataset::attributes, cleanup(), dns_msgblock::count, dns_message::counts, dns_message_find(), DNS_MESSAGEPARSE_BESTEFFORT, dns_name_init(), DNS_R_RECOVERABLE, dns_rdatalist_tordataset(), dns_rdataset_init(), dns_rdataset_isassociated(), DNS_RDATASETATTR_QUESTION, DNS_SECTION_ANY, DNS_SECTION_QUESTION, DO_FORMERR, findname(), getname(), INSIST, isc_buffer_getuint16(), isc_buffer_remainingregion, isc_buffer_setactive, ISC_FALSE, ISC_LIST_APPEND, ISC_LIST_EMPTY, isc_mempool_get, isc_mempool_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, ISC_TF, ISC_TRUE, isc_region::length, name, dns_message::namepool, newoffsets(), newrdatalist(), r, dns_rdatalist::rdclass, dns_message::rdclass, rdclass, dns_message::rdspool, dns_message::sections, dns_message::state, and dns_rdatalist::type.

Referenced by dns_message_parse().

static isc_boolean_t update ( dns_section_t  section,
dns_rdataclass_t  rdclass 
) [static]

Definition at line 1166 of file message.c.

References DNS_SECTION_PREREQUISITE, DNS_SECTION_UPDATE, ISC_FALSE, and ISC_TF.

Referenced by cache_find(), and getsection().

static isc_result_t getsection ( isc_buffer_t source,
dns_message_t msg,
dns_decompress_t dctx,
dns_section_t  sectionid,
unsigned int  options 
) [static]

Definition at line 1176 of file message.c.

References dns_name::attributes, dns_rdataset::attributes, cleanup(), dns_msgblock::count, dns_message::counts, dns_rdatalist::covers, isc_buffer::current, dns_rdata::data, DNS_MESSAGE_EDNSRCODE_MASK, dns_message_find(), DNS_MESSAGEFLAG_QR, DNS_MESSAGEPARSE_BESTEFFORT, DNS_MESSAGEPARSE_PRESERVEORDER, dns_name_equal(), dns_name_init(), DNS_NAMEATTR_NOCOMPRESS, dns_opcode_update, DNS_R_BADOWNERNAME, DNS_R_FORMERR, DNS_R_RECOVERABLE, dns_rdata_checkowner(), dns_rdata_compare(), dns_rdata_covers(), DNS_RDATA_UPDATE, dns_rdatalist_fromrdataset(), dns_rdatalist_tordataset(), dns_rdataset_init(), dns_rdataset_setownercase(), DNS_RDATASETATTR_TTLADJUSTED, dns_rdatatype_issingleton(), dns_rdatatype_questiononly(), dns_rootname, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_ANY, DNS_SECTION_QUESTION, DNS_SECTION_UPDATE, DO_FORMERR, findname(), dns_rdata::flags, dns_message::flags, free_rdataset(), getname(), getrdata(), INSIST, isc_buffer_getuint16(), isc_buffer_getuint32(), isc_buffer_remainingregion, isc_buffer_setactive, ISC_FALSE, ISC_LIST_APPEND, ISC_LIST_HEAD, isc_mempool_get, isc_mempool_put, ISC_R_NOMEMORY, ISC_R_NOTFOUND, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, ISC_TF, ISC_TRUE, dns_rdata::length, isc_region::length, name, dns_message::namepool, newoffsets(), newrdata(), newrdatalist(), dns_message::opcode, dns_message::opt, r, dns_message::rcode, dns_rdatalist::rdclass, dns_rdata::rdclass, dns_message::rdclass, rdclass, dns_message::rdspool, RUNTIME_CHECK, dns_message::sections, dns_message::sig0, dns_message::sig0name, dns_message::sigstart, dns_message::state, dns_message::tsig, dns_message::tsigname, dns_rdataset::ttl, dns_rdatalist::ttl, ttl, dns_rdatalist::type, dns_rdata::type, and update().

Referenced by dns_message_parse().

isc_result_t dns_message_parse ( dns_message_t msg,
isc_buffer_t source,
unsigned int  options 
)

Parse raw wire data in 'source' as a DNS message.

OPT records are detected and stored in the pseudo-section "opt". TSIGs are detected and stored in the pseudo-section "tsig".

If DNS_MESSAGEPARSE_PRESERVEORDER is set, or if the opcode of the message is UPDATE, a separate dns_name_t object will be created for each RR in the message. Each such dns_name_t will have a single rdataset containing the single RR, and the order of the RRs in the message is preserved. Otherwise, only one dns_name_t object will be created for each unique owner name in the section, and each such dns_name_t will have a list of rdatasets. To access the names and their data, use dns_message_firstname() and dns_message_nextname().

If DNS_MESSAGEPARSE_BESTEFFORT is set, errors in message content will not be considered FORMERRs. If the entire message can be parsed, it will be returned and DNS_R_RECOVERABLE will be returned.

If DNS_MESSAGEPARSE_IGNORETRUNCATION is set then return as many complete RR's as possible, DNS_R_RECOVERABLE will be returned.

OPT and TSIG records are always handled specially, regardless of the 'preserve_order' setting.

Requires:

Ensures: Returns:

Definition at line 1593 of file message.c.

References isc_region::base, dns_message::counts, DNS_COMPRESS_GLOBAL14, DNS_DECOMPRESS_ANY, dns_decompress_init(), dns_decompress_setmethods(), dns_lctx, DNS_LOGMODULE_MESSAGE, DNS_MESSAGE_FLAG_MASK, DNS_MESSAGE_HEADERLEN, DNS_MESSAGE_INTENTPARSE, DNS_MESSAGE_OPCODE_MASK, DNS_MESSAGE_OPCODE_SHIFT, DNS_MESSAGE_RCODE_MASK, DNS_MESSAGE_VALID, DNS_MESSAGEPARSE_CLONEBUFFER, DNS_MESSAGEPARSE_IGNORETRUNCATION, DNS_R_RECOVERABLE, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_message::flags, dns_message::free_saved, dns_message::from_to_wire, getquestions(), getsection(), dns_message::header_ok, dns_message::id, isc_buffer_base, isc_buffer_getuint16(), isc_buffer_remainingregion, isc_buffer_usedlength, isc_buffer_usedregion, ISC_FALSE, ISC_LOG_DEBUG, isc_log_write(), ISC_LOGCATEGORY_GENERAL, isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, ISC_TF, ISC_TRUE, isc_region::length, dns_message::mctx, dns_message::opcode, dns_message::question_ok, r, dns_message::rcode, REQUIRE, and dns_message::saved.

Referenced by client_request(), dns_request_getresponse(), recv_done(), resquery_response(), and xfrin_recv_done().

isc_result_t dns_message_renderbegin ( dns_message_t msg,
dns_compress_t cctx,
isc_buffer_t buffer 
)

Begin rendering on a message. Only one call can be made to this function per message.

The compression context is "owned" by the message library until dns_message_renderend() is called. It must be invalidated by the caller.

The buffer is "owned" by the message library until dns_message_renderend() is called.

Requires:

Side Effects:

Returns:

Definition at line 1710 of file message.c.

References dns_message::buffer, dns_message::cctx, DNS_MESSAGE_HEADERLEN, DNS_MESSAGE_INTENTRENDER, DNS_MESSAGE_VALID, dns_message::from_to_wire, isc_buffer_add, isc_buffer_availableregion, isc_buffer_clear, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_region::length, r, REQUIRE, and dns_message::reserved.

Referenced by client_send(), render(), req_render(), resquery_send(), sendstream(), and setup_lookup().

isc_result_t dns_message_renderchangebuffer ( dns_message_t msg,
isc_buffer_t buffer 
)

Reset the buffer. This can be used after growing the old buffer on a ISC_R_NOSPACE return from most of the render functions.

On successful completion, the old buffer is no longer used by the library. The new buffer is owned by the library until dns_message_renderend() is called.

Requires:

Returns:

Definition at line 1749 of file message.c.

References isc_region::base, dns_message::buffer, DNS_MESSAGE_VALID, isc_buffer_add, isc_buffer_availableregion, isc_buffer_clear, isc_buffer_usedregion, ISC_R_SUCCESS, isc_region::length, r, and REQUIRE.

void dns_message_renderrelease ( dns_message_t msg,
unsigned int  space 
)

XXXMLG should use size_t rather than unsigned int once the buffer API is cleaned up.

Release "space" bytes in the given buffer that was previously reserved.

Requires:

Definition at line 1778 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::reserved.

Referenced by dns_message_renderend(), dns_message_settsigkey(), msgresetopt(), and msgresetsigs().

isc_result_t dns_message_renderreserve ( dns_message_t msg,
unsigned int  space 
)

XXXMLG should use size_t rather than unsigned int once the buffer API is cleaned up.

Reserve "space" bytes in the given buffer.

Requires:

Returns:

Definition at line 1786 of file message.c.

References dns_message::buffer, DNS_MESSAGE_VALID, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_region::length, r, REQUIRE, and dns_message::reserved.

Referenced by dns_message_reply(), dns_message_setopt(), dns_message_setsig0key(), and dns_message_settsigkey().

static isc_boolean_t wrong_priority ( dns_rdataset_t rds,
int  pass,
dns_rdatatype_t  preferred_glue 
) [inline, static]

Definition at line 1803 of file message.c.

References ISC_FALSE, ISC_TRUE, dns_rdataset::rdclass, and dns_rdataset::type.

Referenced by dns_message_rendersection().

isc_result_t dns_message_rendersection ( dns_message_t msg,
dns_section_t  section,
unsigned int  options 
)

Render all names, rdatalists, etc from the given section at the specified priority or higher.

Requires:

Returns:

Definition at line 1864 of file message.c.

References dns_rdataset::attributes, dns_message::buffer, dns_message::cctx, dns_msgblock::count, dns_message::counts, dns_compress_rollback(), DNS_MESSAGE_VALID, DNS_MESSAGEFLAG_AD, DNS_MESSAGEFLAG_TC, DNS_MESSAGERENDER_OMITDNSSEC, DNS_MESSAGERENDER_ORDERED, DNS_MESSAGERENDER_PARTIAL, DNS_MESSAGERENDER_PREFER_A, DNS_MESSAGERENDER_PREFER_AAAA, dns_rdataset_towirepartial(), dns_rdataset_towiresorted(), DNS_RDATASETATTR_RENDERED, DNS_RDATASETATTR_REQUIREDGLUE, DNS_RDATASETTOWIRE_OMITDNSSEC, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_trust_secure, dns_message::flags, INSIST, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOSPACE, ISC_R_SUCCESS, ISC_TRUE, isc_buffer::length, name, OPTOUT, dns_message::order, dns_message::order_arg, REQUIRE, dns_message::reserved, dns_message::sections, dns_rdataset::trust, isc_buffer::used, VALID_NAMED_SECTION, and wrong_priority().

Referenced by client_send(), dns_message_renderend(), render(), req_render(), resquery_send(), sendstream(), and setup_lookup().

void dns_message_renderheader ( dns_message_t msg,
isc_buffer_t target 
)

Render the message header. This is implicitly called by dns_message_renderend().

Requires:

Definition at line 2091 of file message.c.

References dns_message::counts, DNS_MESSAGE_FLAG_MASK, DNS_MESSAGE_HEADERLEN, DNS_MESSAGE_OPCODE_MASK, DNS_MESSAGE_OPCODE_SHIFT, DNS_MESSAGE_RCODE_MASK, DNS_MESSAGE_VALID, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_message::flags, dns_message::id, INSIST, isc_buffer_availableregion, isc_buffer_putuint16, isc_region::length, dns_message::opcode, r, dns_message::rcode, and REQUIRE.

Referenced by dns_dnssec_signmessage(), dns_message_renderend(), and dns_tsig_sign().

isc_result_t dns_message_renderend ( dns_message_t msg  ) 

Finish rendering to the buffer. Note that more data can be in the 'msg' structure. Destroying the structure will free this, or in a multi- part EDNS1 message this data can be rendered to another buffer later.

Requires:

Returns:

Definition at line 2125 of file message.c.

References isc_region::base, dns_message::buffer, dns_message::cctx, dns_msgblock::count, dns_message::counts, dns_compress_rollback(), dns_dnssec_signmessage(), DNS_MESSAGE_EDNSRCODE_MASK, DNS_MESSAGE_HEADERLEN, DNS_MESSAGE_RCODE_MASK, dns_message_renderheader(), dns_message_renderrelease(), dns_message_renderreset(), dns_message_rendersection(), DNS_MESSAGE_VALID, DNS_MESSAGEFLAG_TC, DNS_R_FORMERR, dns_rdataset_towire(), dns_rootname, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_QUESTION, dns_tsig_sign(), dns_message::flags, isc_buffer_add, isc_buffer_clear, isc_buffer_init, isc_buffer_usedregion, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_region::length, msgresetnames(), dns_message::opt, dns_message::opt_reserved, r, dns_message::rcode, REQUIRE, dns_message::sig0, dns_message::sig0key, dns_message::sig_reserved, dns_message::tsig, dns_message::tsigkey, dns_message::tsigname, and dns_rdataset::ttl.

Referenced by client_send(), render(), req_render(), resquery_send(), sendstream(), and setup_lookup().

void dns_message_renderreset ( dns_message_t msg  ) 

Reset the message so that it may be rendered again.

Notes:

Requires:

Definition at line 2241 of file message.c.

References dns_rdataset::attributes, dns_message::buffer, dns_message::counts, dns_message::cursors, DNS_MESSAGE_INTENTRENDER, dns_message_puttempname(), dns_message_puttemprdataset(), DNS_MESSAGE_VALID, dns_rdataset_disassociate(), DNS_RDATASETATTR_RENDERED, DNS_SECTION_MAX, dns_message::from_to_wire, ISC_LIST_HEAD, ISC_LIST_NEXT, name, REQUIRE, dns_message::sections, dns_message::sig0, dns_message::tsig, and dns_message::tsigname.

Referenced by dns_message_renderend(), dns_request_createvia4(), receive_soa(), recvsoa(), req_render(), update_completed(), and update_done().

isc_result_t dns_message_firstname ( dns_message_t msg,
dns_section_t  section 
)

Set internal per-section name pointer to the beginning of the section.

The functions dns_message_firstname() and dns_message_nextname() may be used for iterating over the owner names in a section.

Requires:

Returns:

Definition at line 2281 of file message.c.

References dns_message::cursors, DNS_MESSAGE_VALID, ISC_LIST_HEAD, ISC_R_NOMORE, ISC_R_SUCCESS, REQUIRE, dns_message::sections, and VALID_NAMED_SECTION.

Referenced by addoptout(), answer_response(), betterreferral(), cache_message(), chase_additional(), check_for_more_data(), checknamessection(), detailsection(), dns_client_startupdate(), dns_message_sectiontotext(), dns_tkey_processdhresponse(), dns_tkey_processquery(), find_tkey(), findnoqname(), fix_mustbedelegationornxdomain(), followup_lookup(), is_lame(), message_count(), ncache_message(), noanswer_response(), ns_notify_start(), ns_query_start(), ns_update_start(), ns_xfr_start(), printsection(), process_dhtkey(), query_addds(), receive_soa(), recv_done(), recvsoa(), same_question(), setzone(), short_answer(), start_update(), update_action(), val_rdataset_first(), validate_authority(), and xfrin_recv_done().

isc_result_t dns_message_nextname ( dns_message_t msg,
dns_section_t  section 
)

Sets the internal per-section name pointer to point to the next name in that section.

Requires:

Returns:

Definition at line 2294 of file message.c.

References dns_message::cursors, DNS_MESSAGE_VALID, ISC_LIST_NEXT, ISC_R_NOMORE, ISC_R_SUCCESS, REQUIRE, and VALID_NAMED_SECTION.

Referenced by addoptout(), answer_response(), betterreferral(), cache_message(), chase_additional(), check_for_more_data(), checknamessection(), detailsection(), dns_message_sectiontotext(), dns_tkey_processdhresponse(), find_tkey(), findnoqname(), fix_mustbedelegationornxdomain(), followup_lookup(), is_lame(), message_count(), ncache_message(), noanswer_response(), ns_notify_start(), ns_query_start(), ns_update_start(), ns_xfr_start(), printsection(), process_dhtkey(), receive_soa(), recv_done(), recvsoa(), short_answer(), update_action(), val_rdataset_next(), validate_authority(), and xfrin_recv_done().

void dns_message_currentname ( dns_message_t msg,
dns_section_t  section,
dns_name_t **  name 
)

Sets 'name' to point to the name where the per-section internal name pointer is currently set.

This function returns the name in the database, so any data associated with it (via the name's "list" member) contains the actual rdatasets.

Requires:

Definition at line 2308 of file message.c.

References dns_message::cursors, DNS_MESSAGE_VALID, REQUIRE, and VALID_NAMED_SECTION.

Referenced by addoptout(), answer_response(), betterreferral(), cache_message(), chase_additional(), check_for_more_data(), checknamessection(), detailsection(), dns_client_startupdate(), dns_message_sectiontotext(), dns_tkey_processdhresponse(), dns_tkey_processquery(), find_tkey(), findnoqname(), fix_mustbedelegationornxdomain(), followup_lookup(), get_current_rr(), is_lame(), message_count(), ncache_message(), noanswer_response(), ns_notify_start(), ns_query_start(), ns_update_start(), ns_xfr_start(), printsection(), process_dhtkey(), query_addds(), receive_soa(), recv_done(), recvsoa(), same_question(), setzone(), short_answer(), start_update(), val_rdataset_first(), val_rdataset_next(), validate_authority(), and xfrin_recv_done().

isc_result_t dns_message_findname ( dns_message_t msg,
dns_section_t  section,
dns_name_t target,
dns_rdatatype_t  type,
dns_rdatatype_t  covers,
dns_name_t **  foundname,
dns_rdataset_t **  rdataset 
)

Search for a name in the specified section. If it is found, *name is set to point to the name, and *rdataset is set to point to the found rdataset (if type is specified as other than dns_rdatatype_any).

Requires:

Returns:

Definition at line 2320 of file message.c.

References dns_message_findtype(), DNS_R_NXDOMAIN, DNS_R_NXRRSET, findname(), ISC_R_NOTFOUND, ISC_R_SUCCESS, REQUIRE, dns_message::sections, and VALID_SECTION.

Referenced by chase_cnamechain(), check_section(), dns_tkey_processdhresponse(), dns_tkey_processquery(), dns_zone_notifyreceive(), iscname(), query_addrrset(), query_dns64(), query_filter64(), query_isduplicate(), refresh_callback(), and save_nsrrset().

void dns_message_movename ( dns_message_t msg,
dns_name_t name,
dns_section_t  fromsection,
dns_section_t  tosection 
)

Move a name from one section to another.

Requires:

Definition at line 2371 of file message.c.

References DNS_MESSAGE_INTENTRENDER, dns_message::from_to_wire, ISC_LIST_APPEND, ISC_LIST_UNLINK, REQUIRE, dns_message::sections, and VALID_NAMED_SECTION.

void dns_message_addname ( dns_message_t msg,
dns_name_t name,
dns_section_t  section 
)

Adds the name to the given section.

It is the caller's responsibility to enforce any unique name requirements in a section.

Requires:

Definition at line 2389 of file message.c.

References DNS_MESSAGE_INTENTRENDER, dns_message::from_to_wire, ISC_LIST_APPEND, REQUIRE, dns_message::sections, and VALID_NAMED_SECTION.

Referenced by buildquery(), create_query(), dns_client_startupdate(), dns_tkey_builddhquery(), dns_tkey_processquery(), insert_soa(), make_prereq(), notify_createmessage(), query_addadditional(), query_addadditional2(), query_addrrset(), query_dns64(), query_filter64(), query_find(), request_soa(), resquery_send(), send_update(), sendstream(), setup_lookup(), setzone(), start_update(), update_addordelete(), and xfrin_send_request().

void dns_message_removename ( dns_message_t msg,
dns_name_t name,
dns_section_t  section 
)

Remove a existing name from a given section.

It is the caller's responsibility to ensure the name is part of the given section.

Requires:

Definition at line 2401 of file message.c.

References DNS_MESSAGE_INTENTRENDER, dns_message::from_to_wire, ISC_LIST_UNLINK, REQUIRE, dns_message::sections, and VALID_NAMED_SECTION.

Referenced by setzone().

isc_result_t dns_message_gettempname ( dns_message_t msg,
dns_name_t **  item 
)

Return a name that can be used for any temporary purpose, including inserting into the message's linked lists. The name must be returned to the message code using dns_message_puttempname() or inserted into one of the message's sections before the message is destroyed.

It is the caller's responsibility to initialize this name.

Requires:

Returns:

Definition at line 2413 of file message.c.

References DNS_MESSAGE_VALID, dns_name_init(), isc_mempool_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_message::namepool, and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), copy_name(), create_query(), dns_tsig_sign(), insert_soa(), notify_createmessage(), parse_name(), query_add_cname(), query_addns(), query_addsoa(), query_find(), query_newname(), request_soa(), resquery_send(), send_update(), sendstream(), setup_lookup(), setzone(), start_update(), tuple2msgname(), and xfrin_send_request().

isc_result_t dns_message_gettempoffsets ( dns_message_t msg,
dns_offsets_t **  item 
)

Return an offsets array that can be used for any temporary purpose, such as attaching to a temporary name. The offsets will be freed when the message is destroyed or reset.

Requires:

Returns:

Definition at line 2426 of file message.c.

References DNS_MESSAGE_VALID, ISC_R_NOMEMORY, ISC_R_SUCCESS, newoffsets(), and REQUIRE.

isc_result_t dns_message_gettemprdata ( dns_message_t msg,
dns_rdata_t **  item 
)

Return a rdata that can be used for any temporary purpose, including inserting into the message's linked lists. The rdata will be freed when the message is destroyed or reset.

Requires:

Returns:

Definition at line 2438 of file message.c.

References DNS_MESSAGE_VALID, ISC_R_NOMEMORY, ISC_R_SUCCESS, newrdata(), and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), copy_name(), dns_dnssec_signmessage(), dns_message_buildopt(), dns_message_setquerytsig(), dns_tkey_builddhquery(), dns_tsig_sign(), insert_soa(), make_prereq(), notify_createmessage(), query_add_cname(), query_dns64(), query_filter64(), sendstream(), tuple2msgname(), and update_addordelete().

isc_result_t dns_message_gettemprdataset ( dns_message_t msg,
dns_rdataset_t **  item 
)

Return a rdataset that can be used for any temporary purpose, including inserting into the message's linked lists. The name must be returned to the message code using dns_message_puttempname() or inserted into one of the message's sections before the message is destroyed.

Requires:

Returns:

Definition at line 2450 of file message.c.

References DNS_MESSAGE_VALID, dns_rdataset_init(), isc_mempool_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_message::rdspool, and REQUIRE.

Referenced by add_question(), add_rdata_to_list(), buildquery(), copy_name(), create_query(), dns_acache_getentry(), dns_dnssec_signmessage(), dns_message_buildopt(), dns_message_setquerytsig(), dns_tsig_sign(), insert_soa(), make_prereq(), notify_createmessage(), query_add_cname(), query_dns64(), query_filter64(), query_newrdataset(), request_soa(), resquery_send(), send_update(), sendstream(), setzone(), start_update(), tuple2msgname(), update_addordelete(), and xfrin_send_request().

isc_result_t dns_message_gettemprdatalist ( dns_message_t msg,
dns_rdatalist_t **  item 
)

Return a rdatalist that can be used for any temporary purpose, including inserting into the message's linked lists. The rdatalist will be destroyed when the message is destroyed or reset.

Requires:

Returns:

Definition at line 2464 of file message.c.

References DNS_MESSAGE_VALID, ISC_R_NOMEMORY, ISC_R_SUCCESS, newrdatalist(), and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), copy_name(), dns_dnssec_signmessage(), dns_message_buildopt(), dns_message_setquerytsig(), dns_tsig_sign(), insert_soa(), make_prereq(), notify_createmessage(), query_add_cname(), query_dns64(), query_filter64(), sendstream(), tuple2msgname(), and update_addordelete().

void dns_message_puttempname ( dns_message_t msg,
dns_name_t **  item 
)

Return a borrowed name to the message's name free list.

Requires:

Ensures:

Definition at line 2476 of file message.c.

References DNS_MESSAGE_VALID, dns_name_dynamic(), dns_name_free(), isc_mempool_put, dns_message::mctx, dns_message::namepool, and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), copy_name(), create_query(), dns_message_renderreset(), dns_tsig_sign(), free_namelist(), make_prereq(), notify_createmessage(), ns_client_qnamereplace(), query_add_cname(), query_find(), query_releasename(), query_reset(), request_soa(), resquery_send(), send_update(), sendstream(), setup_lookup(), setzone(), start_update(), update_addordelete(), and xfrin_send_request().

void dns_message_puttemprdata ( dns_message_t msg,
dns_rdata_t **  item 
)

Return a borrowed rdata to the message's rdata free list.

Requires:

Ensures:

Definition at line 2487 of file message.c.

References DNS_MESSAGE_VALID, releaserdata(), and REQUIRE.

Referenced by add_rdata_to_list(), dns_message_buildopt(), dns_message_setquerytsig(), dns_tsig_sign(), notify_createmessage(), query_add_cname(), query_dns64(), query_filter64(), sendstream(), tuple2msgname(), and update_addordelete().

void dns_message_puttemprdataset ( dns_message_t msg,
dns_rdataset_t **  item 
)

Return a borrowed rdataset to the message's rdataset free list.

Requires:

Ensures:

Definition at line 2496 of file message.c.

References DNS_MESSAGE_VALID, dns_rdataset_isassociated(), isc_mempool_put, dns_message::rdspool, and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), create_query(), dns_acache_getentry(), dns_message_buildopt(), dns_message_renderreset(), dns_message_setopt(), dns_message_setquerytsig(), exit_check(), free_namelist(), notify_createmessage(), ns_client_endrequest(), query_add_cname(), query_dns64(), query_filter64(), query_find(), query_putrdataset(), request_soa(), resquery_send(), sendstream(), setzone(), start_update(), tuple2msgname(), and xfrin_send_request().

void dns_message_puttemprdatalist ( dns_message_t msg,
dns_rdatalist_t **  item 
)

Return a borrowed rdatalist to the message's rdatalist free list.

Requires:

Ensures:

Definition at line 2506 of file message.c.

References DNS_MESSAGE_VALID, releaserdatalist(), and REQUIRE.

Referenced by add_rdata_to_list(), dns_message_buildopt(), dns_message_setquerytsig(), dns_tsig_sign(), notify_createmessage(), query_add_cname(), query_dns64(), query_filter64(), sendstream(), and tuple2msgname().

isc_result_t dns_message_peekheader ( isc_buffer_t source,
dns_messageid_t idp,
unsigned int *  flagsp 
)

Assume the remaining region of "source" is a DNS message. Peek into it and fill in "*idp" with the message id, and "*flagsp" with the flags.

Requires:

Ensures:

Returns:

Definition at line 2515 of file message.c.

References buffer, DNS_MESSAGE_FLAG_MASK, DNS_MESSAGE_HEADERLEN, isc_buffer_getuint16(), isc_buffer_remainingregion, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, isc_region::length, r, and REQUIRE.

Referenced by client_request(), recv_done(), tcp_recv(), and udp_recv().

isc_result_t dns_message_reply ( dns_message_t msg,
isc_boolean_t  want_question_section 
)

Start formatting a reply to the query in 'msg'.

Requires:

Ensures:

Returns:

Definition at line 2544 of file message.c.

References isc_region::base, DNS_MESSAGE_INTENTRENDER, dns_message_renderreserve(), DNS_MESSAGE_REPLYPRESERVE, DNS_MESSAGE_VALID, DNS_MESSAGEFLAG_QR, dns_opcode_notify, dns_opcode_query, dns_opcode_update, DNS_R_FORMERR, dns_rcode_noerror, DNS_SECTION_ANSWER, DNS_SECTION_PREREQUISITE, DNS_SECTION_QUESTION, dns_tsigerror_badtime, dns_message::flags, dns_message::free_query, dns_message::free_saved, dns_message::from_to_wire, dns_message::header_ok, ISC_FALSE, ISC_R_SUCCESS, ISC_TRUE, isc_region::length, msginitprivate(), msgresetnames(), msgresetopt(), msgresetsigs(), dns_message::opcode, dns_message::query, dns_message::querytsigstatus, dns_message::question_ok, REQUIRE, dns_message::saved, dns_message::sig_reserved, spacefortsig(), dns_message::tsigkey, and dns_message::tsigstatus.

Referenced by dns_tkey_processquery(), ns_client_error(), ns_query_start(), respond(), and sendstream().

dns_rdataset_t* dns_message_getopt ( dns_message_t msg  ) 

Get the OPT record for 'msg'.

Requires:

Returns:

Definition at line 2606 of file message.c.

References DNS_MESSAGE_VALID, dns_message::opt, and REQUIRE.

Referenced by client_request(), dns_message_pseudosectiontotext(), printmessage(), and resquery_response().

isc_result_t dns_message_setopt ( dns_message_t msg,
dns_rdataset_t opt 
)

Set the OPT record for 'msg'.

Requires:

Ensures:

Returns:

Definition at line 2618 of file message.c.

References cleanup(), DNS_MESSAGE_INTENTRENDER, dns_message_puttemprdataset(), dns_message_renderreserve(), DNS_MESSAGE_VALID, DNS_RDATA_INIT, dns_rdataset_current(), dns_rdataset_disassociate(), dns_rdataset_first(), DNS_SECTION_ANY, dns_message::from_to_wire, ISC_R_SUCCESS, dns_rdata::length, msgresetopt(), dns_message::opt, dns_message::opt_reserved, REQUIRE, dns_message::state, and dns_rdataset::type.

Referenced by add_opt(), client_send(), fctx_addopt(), and sendstream().

dns_rdataset_t* dns_message_gettsig ( dns_message_t msg,
dns_name_t **  owner 
)

Get the TSIG record and owner for 'msg'.

Requires:

Returns:

Ensures:

Definition at line 2669 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, dns_message::tsig, and dns_message::tsigname.

Referenced by client_request(), dns_message_pseudosectiontotext(), printmessage(), update_completed(), and xfrin_recv_done().

isc_result_t dns_message_settsigkey ( dns_message_t msg,
dns_tsigkey_t key 
)

Set the tsig key for 'msg'. This is only necessary for when rendering a query or parsing a response. The key (if non-NULL) is attached to, and will be detached when the message is destroyed.

Requires:

Returns:

Definition at line 2684 of file message.c.

References DNS_MESSAGE_INTENTRENDER, dns_message_renderrelease(), dns_message_renderreserve(), DNS_MESSAGE_VALID, DNS_SECTION_ANY, dns_tsigkey_attach(), dns_tsigkey_detach(), dns_message::from_to_wire, ISC_R_SUCCESS, REQUIRE, dns_message::sig0key, dns_message::sig_reserved, spacefortsig(), dns_message::state, and dns_message::tsigkey.

Referenced by dns_request_createvia4(), dns_request_getresponse(), receive_soa(), recv_done(), recvsoa(), resquery_response(), resquery_send(), sendstream(), setup_lookup(), update_completed(), update_done(), xfrin_recv_done(), and xfrin_send_request().

dns_tsigkey_t* dns_message_gettsigkey ( dns_message_t msg  ) 

Gets the tsig key for 'msg'.

Requires:

Definition at line 2719 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::tsigkey.

Referenced by dns_tsig_sign(), dns_tsig_verify(), dns_zone_notifyreceive(), ns_notify_start(), ns_xfr_start(), resquery_send(), tsig_verify_tcp(), and xfrin_recv_done().

isc_result_t dns_message_setquerytsig ( dns_message_t msg,
isc_buffer_t querytsig 
)

Indicates that 'querytsig' is the TSIG from the signed query for which 'msg' is the response. This is also used for chained TSIGs in TCP responses.

Requires:

Returns:

Definition at line 2731 of file message.c.

References isc_region::base, cleanup(), dns_message_gettemprdata(), dns_message_gettemprdatalist(), dns_message_gettemprdataset(), dns_message_puttemprdata(), dns_message_puttemprdatalist(), dns_message_puttemprdataset(), dns_message_takebuffer(), DNS_MESSAGE_VALID, dns_rdata_fromregion(), dns_rdata_init(), dns_rdatalist_tordataset(), isc_buffer_allocate(), isc_buffer_putmem, isc_buffer_usedregion, ISC_LIST_APPEND, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_region::length, dns_message::mctx, dns_message::querytsig, r, and REQUIRE.

Referenced by dns_request_getresponse(), recv_done(), resquery_response(), sendstream(), and xfrin_recv_done().

isc_result_t dns_message_getquerytsig ( dns_message_t msg,
isc_mem_t mctx,
isc_buffer_t **  querytsig 
)

Gets the tsig from the TSIG from the signed query 'msg'. This is also used for chained TSIGs in TCP responses. Unlike dns_message_gettsig, this makes a copy of the data, so can be used if the message is destroyed.

Requires:

Returns:

Ensures:

Definition at line 2785 of file message.c.

References isc_region::base, DNS_MESSAGE_VALID, DNS_RDATA_INIT, dns_rdata_toregion(), dns_rdataset_current(), dns_rdataset_first(), isc_buffer_allocate(), isc_buffer_putmem, ISC_R_SUCCESS, isc_region::length, r, REQUIRE, and dns_message::tsig.

Referenced by dns_request_createvia4(), ns_xfr_start(), recv_done(), resquery_send(), sendstream(), xfrin_recv_done(), and xfrin_send_request().

dns_rdataset_t* dns_message_getsig0 ( dns_message_t msg,
dns_name_t **  owner 
)

Get the SIG(0) record and owner for 'msg'.

Requires:

Returns:

Ensures:

Definition at line 2812 of file message.c.

References DNS_MESSAGE_VALID, dns_rootname, REQUIRE, dns_message::sig0, and dns_message::sig0name.

Referenced by dns_message_pseudosectiontotext().

isc_result_t dns_message_setsig0key ( dns_message_t msg,
dst_key_t key 
)

Set the SIG(0) key for 'msg'.

Requires:

Returns:

Definition at line 2835 of file message.c.

References DNS_MESSAGE_INTENTRENDER, dns_message_renderreserve(), DNS_MESSAGE_VALID, dns_name_toregion(), DNS_SECTION_ANY, dst_key_name(), dst_key_sigsize(), dns_message::from_to_wire, ISC_R_SUCCESS, isc_region::length, r, REQUIRE, dns_message::sig0key, dns_message::sig_reserved, dns_message::state, and dns_message::tsigkey.

Referenced by send_update().

dst_key_t* dns_message_getsig0key ( dns_message_t msg  ) 

Gets the SIG(0) key for 'msg'.

Requires:

Definition at line 2887 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::sig0key.

void dns_message_takebuffer ( dns_message_t msg,
isc_buffer_t **  buffer 
)

Give the *buffer to the message code to clean up when it is no longer needed. This is usually when the message is reset or destroyed.

Requires:

Definition at line 2899 of file message.c.

References dns_message::cleanup, DNS_MESSAGE_VALID, ISC_BUFFER_VALID, ISC_LIST_APPEND, and REQUIRE.

Referenced by add_rdata_to_list(), buildquery(), copy_name(), dns_dnssec_signmessage(), dns_message_buildopt(), dns_message_setquerytsig(), dns_message_signer(), dns_tkey_builddhquery(), dns_tsig_sign(), notify_createmessage(), parse_name(), parse_rdata(), query_dns64(), and query_filter64().

isc_result_t dns_message_signer ( dns_message_t msg,
dns_name_t signer 
)

If this message was signed, return the identity of the signer. Unless ISC_R_NOTFOUND is returned, signer will reflect the name of the key that signed the message.

Requires:

Returns:

Definition at line 2909 of file message.c.

References DNS_MESSAGE_INTENTPARSE, dns_message_takebuffer(), DNS_MESSAGE_VALID, dns_name_clone(), dns_name_hasbuffer(), dns_name_setbuffer(), DNS_R_NOIDENTITY, DNS_R_NOTVERIFIEDYET, DNS_R_SIGINVALID, DNS_R_TSIGERRORSET, DNS_R_TSIGVERIFYFAILURE, dns_rcode_noerror, dns_rdata_freestruct(), DNS_RDATA_INIT, dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_tsigkey_identity, dns_message::from_to_wire, INSIST, isc_buffer_allocate(), ISC_R_NOTFOUND, ISC_R_SUCCESS, dns_message::mctx, dns_tsigkey::name, REQUIRE, dns_message::sig0, dns_message::sig0status, dns_message::tsig, dns_message::tsigkey, dns_message::tsigstatus, dns_message::verified_sig, and dns_message::verify_attempted.

Referenced by client_request(), and dns_tkey_processquery().

void dns_message_resetsig ( dns_message_t msg  ) 

Reset the signature state.

Requires:

Definition at line 2990 of file message.c.

References DNS_MESSAGE_VALID, dns_rcode_noerror, dns_tsigkey_detach(), REQUIRE, dns_message::sig0status, dns_message::timeadjust, dns_message::tsigkey, dns_message::tsigstatus, dns_message::verified_sig, and dns_message::verify_attempted.

Referenced by client_request(), and dns_message_rechecksig().

isc_result_t dns_message_rechecksig ( dns_message_t msg,
dns_view_t view 
)

Reset the signature state and then if the message was signed, verify the message.

Requires:

Returns:

Definition at line 3004 of file message.c.

References dns_message_checksig(), and dns_message_resetsig().

Referenced by client_request().

isc_result_t dns_message_checksig ( dns_message_t msg,
dns_view_t view 
)

If this message was signed, verify the signature.

Requires:

Returns:

Definition at line 3039 of file message.c.

References isc_region::base, dns_rdata::data, dns_dnssec_verifymessage(), DNS_KEYPROTO_ANY, DNS_KEYPROTO_DNSSEC, DNS_MESSAGE_VALID, DNS_R_KEYUNAUTHORIZED, dns_rdata_freestruct(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_disassociate(), dns_rdataset_first(), dns_rdataset_init(), dns_rdataset_isassociated(), dns_rdataset_next(), dns_trust_secure, dns_tsig_verify(), dns_view_checksig(), dns_view_simplefind(), dst_key_alg(), dst_key_free(), dst_key_fromdns(), dst_key_id(), dst_key_proto(), INSIST, isc_buffer_add, isc_buffer_init, ISC_FALSE, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, key, dns_rdata::length, isc_region::length, dns_view::mctx, dns_message::mctx, dns_rdata::rdclass, REQUIRE, dns_message::saved, dns_message::sig0, dns_rdataset::trust, dns_message::tsig, and dns_message::tsigkey.

Referenced by dns_message_rechecksig(), resquery_response(), and xfrin_recv_done().

isc_result_t dns_message_sectiontotext ( dns_message_t msg,
dns_section_t  section,
const dns_master_style_t style,
dns_messagetextflag_t  flags,
isc_buffer_t target 
)

Definition at line 3140 of file message.c.

References ADD_STRING, dns_master_questiontotext(), dns_master_rdatasettotext(), dns_message_currentname(), dns_message_firstname(), dns_message_nextname(), DNS_MESSAGE_VALID, DNS_MESSAGETEXTFLAG_NOCOMMENTS, DNS_MESSAGETEXTFLAG_NOHEADERS, DNS_MESSAGETEXTFLAG_OMITSOA, DNS_MESSAGETEXTFLAG_ONESOA, dns_name_init(), dns_opcode_update, DNS_SECTION_ANSWER, DNS_SECTION_QUESTION, ISC_FALSE, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_TRUE, name, dns_message::opcode, REQUIRE, dns_message::sections, dns_rdataset::type, and VALID_SECTION.

Referenced by dns_message_totext(), and printmessage().

static isc_result_t render_ecs ( isc_buffer_t optbuf,
isc_buffer_t target 
) [static]

Definition at line 3212 of file message.c.

References ADD_STRING, AF_INET6, INSIST, isc_buffer_getuint16(), isc_buffer_getuint8(), isc_buffer_remaininglength, and ISC_R_SUCCESS.

Referenced by dns_message_pseudosectiontotext().

isc_result_t dns_message_pseudosectiontotext ( dns_message_t msg,
dns_pseudosection_t  section,
const dns_master_style_t style,
dns_messagetextflag_t  flags,
isc_buffer_t target 
)

Convert section 'section' or 'pseudosection' of message 'msg' to a cleartext representation.

Notes:

Requires:

Ensures:

Returns:

Definition at line 3248 of file message.c.

References ADD_STRING, dns_rdata::data, dns_master_rdatasettotext(), dns_message_getopt(), dns_message_getsig0(), dns_message_gettsig(), DNS_MESSAGE_VALID, DNS_MESSAGEEXTFLAG_DO, DNS_MESSAGETEXTFLAG_NOCOMMENTS, DNS_MESSAGETEXTFLAG_NOHEADERS, DNS_OPT_CLIENT_SUBNET, DNS_OPT_EXPIRE, DNS_OPT_NSID, DNS_OPT_SIT, DNS_PSEUDOSECTION_OPT, DNS_PSEUDOSECTION_SIG0, DNS_PSEUDOSECTION_TSIG, dns_rdata_init(), dns_rdataset_current(), dns_rdataset_first(), dns_ttl_totext(), INSIST, isc_buffer_add, isc_buffer_availablelength, isc_buffer_current, isc_buffer_forward, isc_buffer_getuint16(), isc_buffer_getuint32(), isc_buffer_init, isc_buffer_putmem, isc_buffer_putstr, isc_buffer_remaininglength, ISC_R_NOSPACE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_TRUE, dns_rdata::length, name, dns_rdataset::rdclass, render_ecs(), REQUIRE, dns_message::sitbad, dns_message::sitok, dns_rdataset::ttl, and VALID_PSEUDOSECTION.

Referenced by dns_message_totext(), and printmessage().

isc_result_t dns_message_totext ( dns_message_t msg,
const dns_master_style_t style,
dns_messagetextflag_t  flags,
isc_buffer_t target 
)

Convert all sections of message 'msg' to a cleartext representation.

Notes:

If DNS_MESSAGETEXTFLAG_ONESOA is set then only print the first SOA record in the answer section. If DNS_MESSAGETEXTFLAG_OMITSOA is set don't print any SOA records in the answer section. These are useful for suppressing the display of the second SOA record in a AXFR by setting DNS_MESSAGETEXTFLAG_ONESOA on the first message in a AXFR stream and DNS_MESSAGETEXTFLAG_OMITSOA on subsequent messages.

Requires:

Ensures:

Returns:

Definition at line 3416 of file message.c.

References ADD_STRING, dns_message::counts, dns_message_pseudosectiontotext(), dns_message_sectiontotext(), DNS_MESSAGE_VALID, DNS_MESSAGEFLAG_AA, DNS_MESSAGEFLAG_AD, DNS_MESSAGEFLAG_CD, DNS_MESSAGEFLAG_QR, DNS_MESSAGEFLAG_RA, DNS_MESSAGEFLAG_RD, DNS_MESSAGEFLAG_TC, DNS_MESSAGETEXTFLAG_NOHEADERS, dns_opcode_update, DNS_PSEUDOSECTION_OPT, DNS_PSEUDOSECTION_SIG0, DNS_PSEUDOSECTION_TSIG, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_message::flags, dns_message::id, ISC_R_SUCCESS, dns_message::opcode, dns_message::rcode, and REQUIRE.

Referenced by _dns_tkey_dumpmessage(), logfmtpacket(), ns_client_dumpmessage(), and show_message().

isc_region_t* dns_message_getrawmessage ( dns_message_t msg  ) 

Retrieve the raw message in compressed wire format. The message must have been successfully parsed for it to have been saved.

Requires:

Returns:

Definition at line 3526 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::saved.

Referenced by client_request(), dns_zone_forwardupdate(), and ns_client_sendraw().

void dns_message_setsortorder ( dns_message_t msg,
dns_rdatasetorderfunc_t  order,
const void *  order_arg 
)

Define the order in which RR sets get rendered by dns_message_rendersection() to be the ascending order defined by the integer value returned by 'order' when given each RR and 'arg' as arguments. If 'order' and 'order_arg' are NULL, a default order is used.

Requires:

Definition at line 3532 of file message.c.

References DNS_MESSAGE_VALID, dns_message::order, dns_message::order_arg, and REQUIRE.

Referenced by setup_query_sortlist().

void dns_message_settimeadjust ( dns_message_t msg,
int  timeadjust 
)

Adjust the time used to sign/verify a message by timeadjust. Currently only TSIG.

Requires:

Definition at line 3541 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::timeadjust.

int dns_message_gettimeadjust ( dns_message_t msg  ) 

Return the current time adjustment.

Requires:

Definition at line 3547 of file message.c.

References DNS_MESSAGE_VALID, REQUIRE, and dns_message::timeadjust.

isc_result_t dns_opcode_totext ( dns_opcode_t  opcode,
isc_buffer_t target 
)

Put a textual representation of error 'opcode' into 'target'.

Requires:

Ensures: Returns:

Definition at line 3553 of file message.c.

References isc_buffer_availablelength, isc_buffer_putstr, ISC_R_NOSPACE, ISC_R_SUCCESS, and REQUIRE.

Referenced by add_bad(), and opcodestat_dump().

void dns_message_logpacket ( dns_message_t message,
const char *  description,
isc_logcategory_t category,
isc_logmodule_t module,
int  level,
isc_mem_t mctx 
)

Definition at line 3564 of file message.c.

References dns_master_style_debug, and logfmtpacket().

void dns_message_logpacket2 ( dns_message_t message,
const char *  description,
isc_sockaddr_t address,
isc_logcategory_t category,
isc_logmodule_t module,
int  level,
isc_mem_t mctx 
)

Definition at line 3573 of file message.c.

References dns_master_style_debug, logfmtpacket(), and REQUIRE.

Referenced by resquery_response(), and xfrin_recv_done().

void dns_message_logfmtpacket ( dns_message_t message,
const char *  description,
isc_logcategory_t category,
isc_logmodule_t module,
const dns_master_style_t style,
int  level,
isc_mem_t mctx 
)

Definition at line 3585 of file message.c.

References logfmtpacket().

void dns_message_logfmtpacket2 ( dns_message_t message,
const char *  description,
isc_sockaddr_t address,
isc_logcategory_t category,
isc_logmodule_t module,
const dns_master_style_t style,
int  level,
isc_mem_t mctx 
)

Log 'message' at the specified logging parameters.

For dns_message_logpacket and dns_message_logfmtpacket expect the 'description' to end in a newline.

For dns_message_logpacket2 and dns_message_logfmtpacket2 'description' will be emitted at the start of the message followed by the formatted address and a newline.

Requires:

Definition at line 3595 of file message.c.

References logfmtpacket(), and REQUIRE.

Referenced by resquery_response(), and resquery_send().

isc_result_t dns_message_buildopt ( dns_message_t msg,
dns_rdataset_t **  opt,
unsigned int  version,
isc_uint16_t  udpsize,
unsigned int  flags,
dns_ednsopt_t ednsopts,
size_t  count 
)

Built a opt record.

Requires:

Returns:

Definition at line 3656 of file message.c.

References cleanup(), dns_rdata::data, dns_message_gettemprdata(), dns_message_gettemprdatalist(), dns_message_gettemprdataset(), dns_message_puttemprdata(), dns_message_puttemprdatalist(), dns_message_puttemprdataset(), dns_message_takebuffer(), DNS_MESSAGE_VALID, dns_rdatalist_tordataset(), dns_rdataset_init(), dns_rdata::flags, isc_buffer_allocate(), isc_buffer_base, isc_buffer_putmem, isc_buffer_putuint16, ISC_LIST_APPEND, ISC_R_NOSPACE, ISC_R_SUCCESS, dns_rdata::length, dns_message::mctx, dns_rdata::rdclass, dns_rdatalist::rdclass, REQUIRE, RUNTIME_CHECK, dns_rdatalist::ttl, dns_rdata::type, and dns_rdatalist::type.

Referenced by add_opt(), fctx_addopt(), and ns_client_addopt().


Variable Documentation

const char* sectiontext[] [static]

Initial value:

 {
        "QUESTION",
        "ANSWER",
        "AUTHORITY",
        "ADDITIONAL"
}
Text representation of the different items, for message_totext functions.

Definition at line 115 of file message.c.

const char* updsectiontext[] [static]

Initial value:

 {
        "ZONE",
        "PREREQUISITE",
        "UPDATE",
        "ADDITIONAL"
}

Definition at line 122 of file message.c.

const char* opcodetext[] [static]

Initial value:

 {
        "QUERY",
        "IQUERY",
        "STATUS",
        "RESERVED3",
        "NOTIFY",
        "UPDATE",
        "RESERVED6",
        "RESERVED7",
        "RESERVED8",
        "RESERVED9",
        "RESERVED10",
        "RESERVED11",
        "RESERVED12",
        "RESERVED13",
        "RESERVED14",
        "RESERVED15"
}

Definition at line 129 of file message.c.

Referenced by printmessage().

const char* rcodetext[] [static]

Initial value:

 {
        "NOERROR",
        "FORMERR",
        "SERVFAIL",
        "NXDOMAIN",
        "NOTIMP",
        "REFUSED",
        "YXDOMAIN",
        "YXRRSET",
        "NXRRSET",
        "NOTAUTH",
        "NOTZONE",
        "RESERVED11",
        "RESERVED12",
        "RESERVED13",
        "RESERVED14",
        "RESERVED15",
        "BADVERS"
}

Definition at line 148 of file message.c.

Referenced by rcode_totext().


Generated on Tue Apr 28 17:41:11 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha