message.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. // Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __MESSAGE_H
  15. #define __MESSAGE_H 1
  16. #include <stdint.h>
  17. #include <iterator>
  18. #include <string>
  19. #include <ostream>
  20. #include <exceptions/exceptions.h>
  21. #include <dns/edns.h>
  22. #include <dns/question.h>
  23. #include <dns/rrset.h>
  24. namespace isc {
  25. namespace dns {
  26. ///
  27. /// \brief A standard DNS module exception that is thrown if a wire format
  28. /// message parser encounters a short length of data that don't even contain
  29. /// the full header section.
  30. ///
  31. class MessageTooShort : public Exception {
  32. public:
  33. MessageTooShort(const char* file, size_t line, const char* what) :
  34. isc::Exception(file, line, what) {}
  35. };
  36. ///
  37. /// \brief A standard DNS module exception that is thrown if a section iterator
  38. /// is being constructed for an incompatible section. Specifically, this
  39. /// happens RRset iterator is being constructed for a Question section.
  40. ///
  41. class InvalidMessageSection : public Exception {
  42. public:
  43. InvalidMessageSection(const char* file, size_t line, const char* what) :
  44. isc::Exception(file, line, what) {}
  45. };
  46. ///
  47. /// \brief A standard DNS module exception that is thrown if a \c Message
  48. /// class method is called that is prohibited for the current mode of
  49. /// the message.
  50. ///
  51. class InvalidMessageOperation : public Exception {
  52. public:
  53. InvalidMessageOperation(const char* file, size_t line, const char* what) :
  54. isc::Exception(file, line, what) {}
  55. };
  56. ///
  57. /// \brief A standard DNS module exception that is thrown if a UDP buffer size
  58. /// smaller than the standard default maximum (DEFAULT_MAX_UDPSIZE) is
  59. /// being specified for the message.
  60. ///
  61. class InvalidMessageUDPSize : public Exception {
  62. public:
  63. InvalidMessageUDPSize(const char* file, size_t line, const char* what) :
  64. isc::Exception(file, line, what) {}
  65. };
  66. typedef uint16_t qid_t;
  67. class InputBuffer;
  68. class MessageRenderer;
  69. class Message;
  70. class MessageImpl;
  71. class Opcode;
  72. class Rcode;
  73. template <typename T>
  74. struct SectionIteratorImpl;
  75. /// \c SectionIterator is a templated class to provide standard-compatible
  76. /// iterators for Questions and RRsets for a given DNS message section.
  77. /// The template parameter is either \c QuestionPtr (for the question section)
  78. /// or \c RRsetPtr (for the answer, authority, or additional section).
  79. template <typename T>
  80. class SectionIterator : public std::iterator<std::input_iterator_tag, T> {
  81. public:
  82. SectionIterator<T>() : impl_(NULL) {}
  83. SectionIterator<T>(const SectionIteratorImpl<T>& impl);
  84. ~SectionIterator<T>();
  85. SectionIterator<T>(const SectionIterator<T>& source);
  86. void operator=(const SectionIterator<T>& source);
  87. SectionIterator<T>& operator++();
  88. SectionIterator<T> operator++(int);
  89. const T& operator*() const;
  90. const T* operator->() const;
  91. bool operator==(const SectionIterator<T>& other) const;
  92. bool operator!=(const SectionIterator<T>& other) const;
  93. private:
  94. SectionIteratorImpl<T>* impl_;
  95. };
  96. typedef SectionIterator<QuestionPtr> QuestionIterator;
  97. typedef SectionIterator<RRsetPtr> RRsetIterator;
  98. /// \brief The \c Message class encapsulates a standard DNS message.
  99. ///
  100. /// Details of the design and interfaces of this class are still in flux.
  101. /// Here are some notes about the current design.
  102. ///
  103. /// Since many realistic DNS applications deal with messages, message objects
  104. /// will be frequently used, and can be performance sensitive. To minimize
  105. /// the performance overhead of constructing and destructing the objects,
  106. /// this class is designed to be reusable. The \c clear() method is provided
  107. /// for this purpose.
  108. ///
  109. /// A \c Message class object is in either the \c PARSE or the \c RENDER mode.
  110. /// A \c PARSE mode object is intended to be used to convert wire-format
  111. /// message data into a complete \c Message object.
  112. /// A \c RENDER mode object is intended to be used to convert a \c Message
  113. /// object into wire-format data.
  114. /// Some of the method functions of this class are limited to a specific mode.
  115. /// In general, "set" type operations are only allowed for \c RENDER mode
  116. /// objects.
  117. /// The initial mode must be specified on construction, and can be changed
  118. /// through some method functions.
  119. ///
  120. /// This class uses the "pimpl" idiom, and hides detailed implementation
  121. /// through the \c impl_ pointer. Since a \c Message object is expected to
  122. /// be reused, the construction overhead of this approach should be acceptable.
  123. ///
  124. /// Open issues (among other things):
  125. /// - We may want to provide an "iterator" for all RRsets/RRs for convenience.
  126. /// This will be for applications that do not care about performance much,
  127. /// so the implementation can only be moderately efficient.
  128. /// - We may want to provide a "find" method for a specified type
  129. /// of RR in the message.
  130. class Message {
  131. public:
  132. /// Constants to specify the operation mode of the \c Message.
  133. enum Mode {
  134. PARSE = 0, ///< Parse mode (handling an incoming message)
  135. RENDER = 1 ///< Render mode (building an outgoing message)
  136. };
  137. /// \brief Constants for flag bit fields of a DNS message header.
  138. ///
  139. /// Only the defined constants are valid where a header flag is required
  140. /// in this library (e.g., in \c Message::setHeaderFlag()).
  141. /// Since these are enum constants, however, an invalid value could be
  142. /// passed via casting without an error at compilation time.
  143. /// It is generally the callee's responsibility to check and reject invalid
  144. /// values.
  145. /// Of course, applications shouldn't pass invalid values even if the
  146. /// callee does not perform proper validation; the result in such usage
  147. /// is undefined.
  148. ///
  149. /// In the current implementation, the defined values happen to be
  150. /// a 16-bit integer with one bit being set corresponding to the
  151. /// specified flag in the second 16 bits of the DNS Header section
  152. /// in order to make the internal implementation simpler.
  153. /// For example, \c HEADERFLAG_QR is defined to be 0x8000 as the QR
  154. /// bit is the most significant bit of the second 16 bits of the header.
  155. /// However, applications should not assume this coincidence and
  156. /// must solely use the enum representations.
  157. /// Any usage based on the assumption of the underlying values is invalid
  158. /// and the result is undefined.
  159. ///
  160. /// Likewise, bit wise operations such as AND or OR on the flag values
  161. /// are invalid and are not guaranteed to work, even if it could compile
  162. /// with casting.
  163. /// For example, the following code will compile:
  164. /// \code const uint16_t combined_flags =
  165. /// static_cast<uint16_t>(Message::HEADERFLAG_AA) |
  166. /// static_cast<uint16_t>(Message::HEADERFLAG_CD);
  167. /// message->setHeaderFlag(static_cast<Message::HeaderFlag>(combined_flags));
  168. /// \endcode
  169. /// and (with the current definition) happens to work as if it were
  170. /// validly written as follows:
  171. /// \code message->setHeaderFlag(Message::HEADERFLAG_AA);
  172. /// message->setHeaderFlag(Message::HEADERFLAG_CD);
  173. /// \endcode
  174. /// But the former notation is invalid and may not work in future versions.
  175. /// We did not try to prohibit such usage at compilation time, e.g., by
  176. /// introducing a separately defined class considering the balance
  177. /// between the complexity and advantage, but hopefully the cast notation
  178. /// is sufficiently ugly to prevent proliferation of the usage.
  179. enum HeaderFlag {
  180. HEADERFLAG_QR = 0x8000, ///< Query (if cleared) or response (if set)
  181. HEADERFLAG_AA = 0x0400, ///< Authoritative answer
  182. HEADERFLAG_TC = 0x0200, ///< Truncation
  183. HEADERFLAG_RD = 0x0100, ///< Recursion desired
  184. HEADERFLAG_RA = 0x0080, ///< Recursion available
  185. HEADERFLAG_AD = 0x0020, ///< DNSSEC checking disabled (RFC4035)
  186. HEADERFLAG_CD = 0x0010 ///< Authentic %data (RFC4035)
  187. };
  188. /// \brief Constants to specify sections of a DNS message.
  189. ///
  190. /// The sections are those defined in RFC 1035 excluding the Header
  191. /// section; the fields of the Header section are accessed via specific
  192. /// methods of the \c Message class (e.g., \c getQid()).
  193. ///
  194. /// <b>Open Design Issue:</b>
  195. /// In the current implementation the values for the constants are
  196. /// sorted in the order of appearance in DNS messages, i.e.,
  197. /// from %Question to Additional.
  198. /// So, for example,
  199. /// code <code>section >= Message::SECTION_AUTHORITY</code> can be
  200. /// used to do something in or after the Authority section.
  201. /// This would be convenient, but it is not clear if it's really a good
  202. /// idea to rely on relationship between the underlying values of enum
  203. /// constants. At the moment, applications are discouraged to rely on
  204. /// this implementation detail. We will see if such usage is sufficiently
  205. /// common to officially support it.
  206. ///
  207. /// Note also that since we don't define \c operator++ for this enum,
  208. /// the following code intending to iterate over all sections will
  209. /// \b not compile:
  210. /// \code for (Section s; s <= SECTION_ADDITIONAL; ++s) { // ++s undefined
  211. /// // do something
  212. /// } \endcode
  213. /// This is intentional at this moment, and we'll see if we need to allow
  214. /// that as we have more experiences with this library.
  215. ///
  216. /// <b>Future Extension:</b> We'll probably also define constants for
  217. /// the section names used in dynamic updates in future versions.
  218. enum Section {
  219. SECTION_QUESTION = 0, ///< %Question section
  220. SECTION_ANSWER = 1, ///< Answer section
  221. SECTION_AUTHORITY = 2, ///< Authority section
  222. SECTION_ADDITIONAL = 3 ///< Additional section
  223. };
  224. ///
  225. /// \name Constructors and Destructor
  226. ///
  227. /// Note: The copy constructor and the assignment operator are
  228. /// intentionally defined as private.
  229. /// The intended use case wouldn't require copies of a \c Message object;
  230. /// once created, it would normally be expected to be reused, changing the
  231. /// mode from \c PARSE to \c RENDER, and vice versa.
  232. //@{
  233. public:
  234. /// \brief The constructor.
  235. /// The mode of the message is specified by the \c mode parameter.
  236. Message(Mode mode);
  237. /// \brief The destructor.
  238. ~Message();
  239. private:
  240. Message(const Message& source);
  241. Message& operator=(const Message& source);
  242. //@}
  243. public:
  244. /// \brief Return whether the specified header flag bit is set in the
  245. /// header section.
  246. ///
  247. /// This method is basically exception free, but if
  248. /// \c flag is not a valid constant of the \c HeaderFlag type,
  249. /// an exception of class \c InvalidParameter will be thrown.
  250. ///
  251. /// \param flag The header flag constant to test.
  252. /// \return \c true if the specified flag is set; otherwise \c false.
  253. bool getHeaderFlag(const HeaderFlag flag) const;
  254. /// \brief Set or clear the specified header flag bit in the header
  255. /// section.
  256. ///
  257. /// The optional parameter \c on indicates the operation mode,
  258. /// set or clear; if it's \c true the corresponding flag will be set;
  259. /// otherwise the flag will be cleared.
  260. /// In either case the original state of the flag does not affect the
  261. /// operation; for example, if a flag is already set and the "set"
  262. /// operation is attempted, it effectively results in no operation.
  263. ///
  264. /// The parameter \c on can be omitted, in which case a value of \c true
  265. /// (i.e., set operation) will be assumed.
  266. /// This is based on the observation that the flag would have to be set
  267. /// in the vast majority of the cases where an application needs to
  268. /// use this method.
  269. ///
  270. /// This method is only allowed in the \c RENDER mode;
  271. /// if the \c Message is in other mode, an exception of class
  272. /// InvalidMessageOperation will be thrown.
  273. ///
  274. /// If \c flag is not a valid constant of the \c HeaderFlag type,
  275. /// an exception of class \c InvalidParameter will be thrown.
  276. ///
  277. /// \param flag The header flag constant to set or clear.
  278. /// \param on If \c true the flag will be set; otherwise the flag will be
  279. /// cleared.
  280. void setHeaderFlag(const HeaderFlag flag, const bool on = true);
  281. /// \brief Return the query ID given in the header section of the message.
  282. qid_t getQid() const;
  283. /// \brief Set the query ID of the header section of the message.
  284. ///
  285. /// This method is only allowed in the \c RENDER mode;
  286. /// if the \c Message is in other mode, an exception of class
  287. /// InvalidMessageOperation will be thrown.
  288. void setQid(qid_t qid);
  289. /// \brief Return the Response Code of the message.
  290. ///
  291. /// This includes extended codes specified by an EDNS OPT RR (when
  292. /// included). In the \c PARSE mode, if the received message contains
  293. /// an EDNS OPT RR, the corresponding extended code is identified and
  294. /// returned.
  295. ///
  296. /// The message must have been properly parsed (in the case of the
  297. /// \c PARSE mode) or an \c Rcode has been set (in the case of the
  298. /// \c RENDER mode) beforehand. Otherwise, an exception of class
  299. /// \c InvalidMessageOperation will be thrown.
  300. const Rcode& getRcode() const;
  301. /// \brief Set the Response Code of the message.
  302. ///
  303. /// This method is only allowed in the \c RENDER mode;
  304. /// if the \c Message is in other mode, an exception of class
  305. /// InvalidMessageOperation will be thrown.
  306. ///
  307. /// If the specified code is an EDNS extended RCODE, an EDNS OPT RR will be
  308. /// included in the message.
  309. void setRcode(const Rcode& rcode);
  310. /// \brief Return the OPCODE given in the header section of the message.
  311. ///
  312. /// The message must have been properly parsed (in the case of the
  313. /// \c PARSE mode) or an \c Opcode has been set (in the case of the
  314. /// \c RENDER mode) beforehand. Otherwise, an exception of class
  315. /// \c InvalidMessageOperation will be thrown.
  316. const Opcode& getOpcode() const;
  317. /// \brief Set the OPCODE of the header section of the message.
  318. ///
  319. /// This method is only allowed in the \c RENDER mode;
  320. /// if the \c Message is in other mode, an exception of class
  321. /// InvalidMessageOperation will be thrown.
  322. void setOpcode(const Opcode& opcode);
  323. /// \brief Return, if any, the EDNS associated with the message.
  324. ///
  325. /// This method never throws an exception.
  326. ///
  327. /// \return A shared pointer to the EDNS. This will be a null shared
  328. /// pointer if the message is not associated with EDNS.
  329. ConstEDNSPtr getEDNS() const;
  330. /// \brief Set EDNS for the message.
  331. ///
  332. /// This method is only allowed in the \c RENDER mode;
  333. /// if the \c Message is in other mode, an exception of class
  334. /// InvalidMessageOperation will be thrown.
  335. ///
  336. /// \param edns A shared pointer to an \c EDNS object to be set in
  337. /// \c Message.
  338. void setEDNS(ConstEDNSPtr edns);
  339. /// \brief Returns the number of RRs contained in the given section.
  340. ///
  341. /// In the \c PARSE mode, the returned value may not be identical to
  342. /// the actual number of RRs of the incoming message that is parsed.
  343. /// The \c Message class handles some "meta" RRs such as EDNS OPT RR
  344. /// separately. This method doesn't include such RRs.
  345. /// Also, a future version of the parser will detect and unify duplicate
  346. /// RRs (which should be rare in practice though), in which case
  347. /// the stored RRs in the \c Message object will be fewer than the RRs
  348. /// originally contained in the incoming message.
  349. ///
  350. /// Likewise, in the \c RENDER mode, even if \c EDNS is set in the
  351. /// \c Message, this method doesn't count the corresponding OPT RR
  352. /// in the Additional section.
  353. ///
  354. /// This method is basically exception free, but if
  355. /// \c section is not a valid constant of the \c Section type,
  356. /// an exception of class \c OutOfRange will be thrown.
  357. ///
  358. /// \param section The section in the message where RRs should be
  359. /// counted.
  360. /// \return The number of RRs stored in the specified section of the
  361. /// message.
  362. unsigned int getRRCount(const Section section) const;
  363. /// \brief Return an iterator corresponding to the beginning of the
  364. /// Question section of the message.
  365. const QuestionIterator beginQuestion() const;
  366. /// \brief Return an iterator corresponding to the end of the
  367. /// Question section of the message.
  368. const QuestionIterator endQuestion() const;
  369. /// \brief Return an iterator corresponding to the beginning of the
  370. /// given section (other than Question) of the message.
  371. ///
  372. /// \c section must be a valid constant of the \c Section type;
  373. /// otherwise, an exception of class \c OutOfRange will be thrown.
  374. const RRsetIterator beginSection(const Section section) const;
  375. /// \brief Return an iterator corresponding to the end of the
  376. /// given section (other than Question) of the message.
  377. ///
  378. /// \c section must be a valid constant of the \c Section type;
  379. /// otherwise, an exception of class \c OutOfRange will be thrown.
  380. const RRsetIterator endSection(const Section section) const;
  381. /// \brief Add a (pointer like object of) Question to the message.
  382. ///
  383. /// This method is only allowed in the \c RENDER mode;
  384. /// if the \c Message is in other mode, an exception of class
  385. /// InvalidMessageOperation will be thrown.
  386. void addQuestion(QuestionPtr question);
  387. /// \brief Add a (pointer like object of) Question to the message.
  388. ///
  389. /// This version internally creates a \c QuestionPtr object from the
  390. /// given \c question and calls the other version of this method.
  391. /// So this is inherently less efficient, but is provided because this
  392. /// form may be more intuitive and may make more sense for performance
  393. /// insensitive applications.
  394. ///
  395. /// This method is only allowed in the \c RENDER mode;
  396. /// if the \c Message is in other mode, an exception of class
  397. /// InvalidMessageOperation will be thrown.
  398. void addQuestion(const Question& question);
  399. /// \brief Add a (pointer like object of) RRset to the given section
  400. /// of the message.
  401. ///
  402. /// This interface takes into account the RRSIG possibly attached to
  403. /// \c rrset. This interface design needs to be revisited later.
  404. ///
  405. /// This method is only allowed in the \c RENDER mode;
  406. /// if the \c Message is in other mode, an exception of class
  407. /// InvalidMessageOperation will be thrown.
  408. /// \c section must be a valid constant of the \c Section type;
  409. /// otherwise, an exception of class \c OutOfRange will be thrown.
  410. ///
  411. /// Note that \c addRRset() does not currently check for duplicate
  412. /// data before inserting RRsets. The caller is responsible for
  413. /// checking for these (see \c hasRRset() below).
  414. void addRRset(const Section section, RRsetPtr rrset, bool sign = false);
  415. /// \brief Determine whether the given section already has an RRset
  416. /// matching the given name, RR class and RR type.
  417. ///
  418. /// \c section must be a valid constant of the \c Section type;
  419. /// otherwise, an exception of class \c OutOfRange will be thrown.
  420. ///
  421. /// This should probably be extended to be a "find" method that returns
  422. /// a matching RRset if found.
  423. bool hasRRset(const Section section, const Name& name,
  424. const RRClass& rrclass, const RRType& rrtype);
  425. /// \brief Determine whether the given section already has an RRset
  426. /// matching the one pointed to by the argumet
  427. ///
  428. /// \c section must be a valid constant of the \c Section type;
  429. /// otherwise, an exception of class \c OutOfRange will be thrown.
  430. bool hasRRset(const Section section, const RRsetPtr& rrset);
  431. /// \brief Remove RRSet from Message
  432. ///
  433. /// Removes the RRset identified by the section iterator from the message.
  434. /// Note: if,.for some reason, the RRset is duplicated in the section, only
  435. /// one occurrence is removed.
  436. ///
  437. /// If the operation is successful, all iterators into the section are
  438. /// invalidated.
  439. ///
  440. /// \param section Section to which the iterator belongs
  441. /// \param iterator Iterator pointing to the element to be removed
  442. ///
  443. /// \return true if the element was removed, false if the iterator was not
  444. /// found in the specified section.
  445. bool removeRRset(const Section section, RRsetIterator& iterator);
  446. /// \brief Remove all RRSets from the given Section
  447. ///
  448. /// \param section Section to remove all rrsets from
  449. void clearSection(const Section section);
  450. // The following methods are not currently implemented.
  451. //void removeQuestion(QuestionPtr question);
  452. // notyet:
  453. //void addRR(const Section section, const RR& rr);
  454. //void removeRR(const Section section, const RR& rr);
  455. /// \brief Clear the message content (if any) and reinitialize it in the
  456. /// specified mode.
  457. void clear(Mode mode);
  458. /// \brief Adds all rrsets from the source the given section in the
  459. /// source message to the same section of this message
  460. ///
  461. /// \param section the section to append
  462. /// \param target The source Message
  463. void appendSection(const Section section, const Message& source);
  464. /// \brief Prepare for making a response from a request.
  465. ///
  466. /// This will clear the DNS header except those fields that should be kept
  467. /// for the response, and clear answer and the following sections.
  468. /// See also dns_message_reply() of BIND9.
  469. void makeResponse();
  470. /// \brief Convert the Message to a string.
  471. ///
  472. /// At least \c Opcode and \c Rcode must be validly set in the \c Message
  473. /// (as a result of parse in the \c PARSE mode or by explicitly setting
  474. /// in the \c RENDER mode); otherwise, an exception of
  475. /// class \c InvalidMessageOperation will be thrown.
  476. std::string toText() const;
  477. /// \brief Render the message in wire formant into a \c MessageRenderer
  478. /// object.
  479. ///
  480. /// This \c Message must be in the \c RENDER mode and both \c Opcode and
  481. /// \c Rcode must have been set beforehand; otherwise, an exception of
  482. /// class \c InvalidMessageOperation will be thrown.
  483. void toWire(MessageRenderer& renderer);
  484. /// \brief Parse the header section of the \c Message.
  485. void parseHeader(InputBuffer& buffer);
  486. /// \brief Parse the \c Message.
  487. void fromWire(InputBuffer& buffer);
  488. ///
  489. /// \name Protocol constants
  490. ///
  491. //@{
  492. /// \brief The default maximum size of UDP DNS messages that don't cause
  493. /// truncation.
  494. ///
  495. /// With EDNS the maximum size can be increased per message.
  496. static const uint16_t DEFAULT_MAX_UDPSIZE = 512;
  497. /// \brief The default maximum size of UDP DNS messages we can handle
  498. static const uint16_t DEFAULT_MAX_EDNS0_UDPSIZE = 4096;
  499. //@}
  500. private:
  501. MessageImpl* impl_;
  502. };
  503. /// \brief Pointer-like type pointing to a \c Message
  504. ///
  505. /// This type is expected to be used as an argument in asynchronous
  506. /// callback functions. The internal reference-counting will ensure that
  507. /// that ongoing state information will not be lost if the object
  508. /// that originated the asynchronous call falls out of scope.
  509. typedef boost::shared_ptr<Message> MessagePtr;
  510. std::ostream& operator<<(std::ostream& os, const Message& message);
  511. }
  512. }
  513. #endif // __MESSAGE_H
  514. // Local Variables:
  515. // mode: c++
  516. // End: