├── .clang-format
├── .gitignore
├── CHANGES
├── COPYING
├── COPYING.LESSER
├── README.md
├── fmt.sh
├── hexdns2text
├── .gitignore
├── Makefile.am
├── autogen.sh
├── configure.ac
├── hexdns2text.c
└── test
│ ├── Makefile.am
│ ├── test1.gold
│ ├── test1.sh
│ ├── test2.gold
│ └── test2.sh
├── omg_dns.c
└── omg_dns.h
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: webkit
2 | IndentWidth: 4
3 | AlignConsecutiveAssignments: true
4 | AlignConsecutiveDeclarations: true
5 | AlignOperands: true
6 | SortIncludes: false
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.ko
3 | *.obj
4 | *.elf
5 | *.gch
6 | *.pch
7 | *.lib
8 | *.a
9 | *.la
10 | *.lo
11 | *.dll
12 | *.so
13 | *.so.*
14 | *.dylib
15 | *.exe
16 | *.out
17 | *.app
18 | *.i*86
19 | *.x86_64
20 | *.hex
21 | *.dSYM/
22 | *.su
23 | .deps
24 | .libs
25 | .dirstamp
26 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 | 2017-03-28 Jerry Lundström
2 |
3 | Release 1.0.0
4 |
5 | First release of OMG-DNS.
6 |
7 | c280bef Touch up readme
8 | b8b9f31 Implement HIP support
9 | 716a7fa Fix automake files to handle building in build dir
10 | 9ebe0b6 Split parsing of header and RRs
11 | 2de2d37 Moved C++ extern and add missing version functions declare
12 | fcc79bf Make example code runnable
13 | b144309 Update README and copyright date
14 | 759cba0 Update Travis/Coverity status badges
15 | 6082526 First implementation
16 | a58c601 Initial commit
17 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/COPYING.LESSER:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # omg-dns
2 |
3 | Helper library for parsing valid/invalid/broken/malformed DNS packets
4 |
5 | ## About
6 |
7 | This is a helper library intended to be included within other projects
8 | repositories as a submodule to help them parse DNS packets. It will parse
9 | as much as possible and will indicate where and what failed if any.
10 |
11 | Supported RFCs:
12 | - todo
13 |
14 | ## Usage
15 |
16 | Here is a short example how to use this library, for a more complete program
17 | check `hexdns2text/hexdns2text.c`.
18 |
19 | ```c
20 | #include "omg-dns/omg_dns.h"
21 | #include
22 |
23 | struct context {
24 | size_t num_rr;
25 | size_t num_label;
26 | };
27 |
28 | static int label_callback(const omg_dns_label_t* label, void* vp) {
29 | struct context* context = (struct context*)vp;
30 |
31 | printf(" label %lu:\n", context->num_label++);
32 | if (omg_dns_label_is_end(label))
33 | printf(" end: yes\n");
34 | else if (!omg_dns_label_is_complete(label))
35 | printf(" incomplete: yes\n");
36 | else if (omg_dns_label_have_offset(label))
37 | printf(" offset: %d\n", omg_dns_label_offset(label));
38 | else if (omg_dns_label_have_extension_bits(label))
39 | printf(" extension_bits: %02x\n", omg_dns_label_extension_bits(label));
40 |
41 | return OMG_DNS_OK;
42 | }
43 |
44 | static int rr_callback(int ret, const omg_dns_rr_t* rr, void* vp) {
45 | struct context* context = (struct context*)vp;
46 |
47 | printf(" rr %lu:\n", context->num_rr++);
48 | printf(" question: %s\n", omg_dns_rr_is_question(rr) ? "yes" : "no");
49 | if (omg_dns_rr_have_type(rr))
50 | printf(" type: %u\n", omg_dns_rr_type(rr));
51 |
52 | return OMG_DNS_OK;
53 | }
54 |
55 | int main(void) {
56 | omg_dns_t dns = OMG_DNS_T_INIT;
57 | struct context context = { 0, 0 };
58 | uint8_t packet[] = { ... raw dns packet as byte array ... };
59 |
60 | omg_dns_set_rr_callback(&dns, rr_callback, (void*)&context);
61 | omg_dns_set_label_callback(&dns, label_callback, (void*)&context);
62 | omg_dns_parse(&dns, packet, sizeof(packet));
63 |
64 | if (omg_dns_have_id(&dns))
65 | printf("id: %u\n", omg_dns_id(&dns));
66 |
67 | return 0;
68 | }
69 | ```
70 |
71 | ### git submodule
72 |
73 | ```shell
74 | git submodule init
75 | git submodule add https://github.com/DNS-OARC/omg-dns.git src/omg-dns
76 | ```
77 |
78 | ### Makefile.am
79 |
80 | ```m4
81 | program_SOURCES += omg-dns/omg_dns.c
82 | dist_program_SOURCES += omg-dns/omg_dns.h
83 | ```
84 |
85 | ## Author(s)
86 |
87 | Jerry Lundström
88 |
89 | ## Copyright
90 |
91 | Copyright (c) 2017, OARC, Inc.
92 | All rights reserved.
93 |
94 | This file is part of omg-dns.
95 |
96 | omg-dns is free software: you can redistribute it and/or modify
97 | it under the terms of the GNU Lesser General Public License as published by
98 | the Free Software Foundation, either version 3 of the License, or
99 | (at your option) any later version.
100 |
101 | omg-dns is distributed in the hope that it will be useful,
102 | but WITHOUT ANY WARRANTY; without even the implied warranty of
103 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 | GNU Lesser General Public License for more details.
105 |
106 | You should have received a copy of the GNU Lesser General Public License
107 | along with omg-dns. If not, see .
108 |
--------------------------------------------------------------------------------
/fmt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | clang-format-4.0 \
4 | -style=file \
5 | -i \
6 | omg_dns.c \
7 | omg_dns.h \
8 | hexdns2text/hexdns2text.c
9 |
--------------------------------------------------------------------------------
/hexdns2text/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile.in
2 | aclocal.m4
3 | autom4te.cache/
4 | compile
5 | config.guess
6 | config.h.in
7 | config.h.in~
8 | config.sub
9 | configure
10 | depcomp
11 | install-sh
12 | missing
13 | Makefile
14 | config.h
15 | config.log
16 | config.status
17 | omg_dns.c
18 | omg_dns.h
19 | stamp-h1
20 | hexdns2text
21 | test-driver
22 | test/test-suite.log
23 | test/test*.sh.log
24 | test/test*.sh.trs
25 | build/
26 |
--------------------------------------------------------------------------------
/hexdns2text/Makefile.am:
--------------------------------------------------------------------------------
1 | # Author Jerry Lundström
2 | # Copyright (c) 2017, OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of omg-dns.
6 | #
7 | # omg-dns is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU Lesser General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # omg-dns is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public License
18 | # along with omg-dns. If not, see .
19 |
20 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
21 | CLEANFILES = omg_dns.c omg_dns.h
22 |
23 | SUBDIRS = test
24 |
25 | AM_CFLAGS = -Wall -I$(srcdir) -I$(top_srcdir)/../
26 |
27 | bin_PROGRAMS = hexdns2text
28 |
29 | hexdns2text_SOURCES = hexdns2text.c omg_dns.c
30 |
31 | omg_dns.c: $(top_srcdir)/../omg_dns.c omg_dns.h
32 | cp "$(top_srcdir)/../omg_dns.c" .
33 |
34 | omg_dns.h: $(top_srcdir)/../omg_dns.h
35 | cp "$(top_srcdir)/../omg_dns.h" .
36 |
37 | test: check
38 |
--------------------------------------------------------------------------------
/hexdns2text/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | #
3 | # Author Jerry Lundström
4 | # Copyright (c) 2017, OARC, Inc.
5 | # All rights reserved.
6 | #
7 | # This file is part of omg-dns.
8 | #
9 | # omg-dns is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU Lesser General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # omg-dns is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU Lesser General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU Lesser General Public License
20 | # along with omg-dns. If not, see .
21 |
22 | autoreconf --force --install --no-recursive
23 |
--------------------------------------------------------------------------------
/hexdns2text/configure.ac:
--------------------------------------------------------------------------------
1 | # Author Jerry Lundström
2 | # Copyright (c) 2017, OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of omg-dns.
6 | #
7 | # omg-dns is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU Lesser General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # omg-dns is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public License
18 | # along with omg-dns. If not, see .
19 |
20 | AC_PREREQ(2.61)
21 | AC_INIT([hexdns2text], [1.0.0], [admin@dns-oarc.net], [hexdns2text], [https://github.com/DNS-OARC/omg-dns/issues])
22 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
23 | AC_CONFIG_SRCDIR([hexdns2text.c])
24 | AC_CONFIG_HEADER([config.h])
25 |
26 | AC_PROG_CC
27 | AM_PROG_CC_C_O
28 |
29 | AC_CONFIG_FILES([Makefile test/Makefile])
30 | AC_OUTPUT
31 |
--------------------------------------------------------------------------------
/hexdns2text/hexdns2text.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Author Jerry Lundström
3 | * Copyright (c) 2017, OARC, Inc.
4 | * All rights reserved.
5 | *
6 | * This file is part of omg-dns.
7 | *
8 | * omg-dns is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * omg-dns is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with omg-dns. If not, see .
20 | */
21 |
22 | #include "config.h"
23 | #include "omg_dns.h"
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #define NUM_LABELS 512
31 | struct labels {
32 | uint8_t* data;
33 | size_t label_idx;
34 | omg_dns_label_t* label;
35 | };
36 |
37 | #define NUM_RRS 128
38 | struct rrs {
39 | size_t rr_idx;
40 | omg_dns_rr_t* rr;
41 | int* ret;
42 | size_t* label_idx;
43 | struct labels* labels;
44 | };
45 |
46 | static int print_labels = 0;
47 |
48 | static int hex2byte(char hex)
49 | {
50 | if (hex >= '0' && hex <= '9') {
51 | return hex - '0';
52 | } else if (hex >= 'a' && hex <= 'f') {
53 | return hex - 'a' + 10;
54 | } else if (hex >= 'A' && hex <= 'F') {
55 | return hex - 'A' + 10;
56 | }
57 |
58 | return -1;
59 | }
60 |
61 | static void print_label(const omg_dns_label_t* label, const uint8_t* data, const char* prefix)
62 | {
63 | if (!label)
64 | return;
65 |
66 | printf("%slabel:\n", prefix ? prefix : "");
67 | if (omg_dns_label_is_end(label)) {
68 | printf("%s end: yes\n", prefix ? prefix : "");
69 | return;
70 | }
71 | if (!omg_dns_label_is_complete(label)) {
72 | printf("%s incomplete: yes\n", prefix ? prefix : "");
73 | return;
74 | }
75 |
76 | if (omg_dns_label_have_offset(label)) {
77 | printf("%s offset: %d\n", prefix ? prefix : "", omg_dns_label_offset(label));
78 | } else if (omg_dns_label_have_extension_bits(label)) {
79 | printf("%s extension_bits: %02x\n", prefix ? prefix : "", omg_dns_label_extension_bits(label));
80 | } else if (omg_dns_label_have_dn(label)) {
81 | if (data) {
82 | const uint8_t* dn = data + omg_dns_label_dn_offset(label);
83 | size_t dnlen = omg_dns_label_length(label);
84 |
85 | printf("%s dn: ", prefix ? prefix : "");
86 | while (dnlen--) {
87 | printf("%c", *dn++);
88 | }
89 | printf("\n");
90 | } else {
91 | printf("%s dn: NO_DATA\n", prefix ? prefix : "");
92 | }
93 | } else {
94 | printf("%s invalid: yes\n", prefix ? prefix : "");
95 | }
96 | }
97 |
98 | static int label_callback(const omg_dns_label_t* label, void* context)
99 | {
100 | struct labels* labels = (struct labels*)context;
101 |
102 | if (labels->label_idx == NUM_LABELS)
103 | return OMG_DNS_ENOMEM;
104 |
105 | labels->label[labels->label_idx] = *label;
106 | labels->label_idx++;
107 |
108 | return OMG_DNS_OK;
109 | }
110 |
111 | static int rr_callback(int ret, const omg_dns_rr_t* rr, void* context)
112 | {
113 | struct rrs* rrs = (struct rrs*)context;
114 |
115 | if (rrs->rr_idx == NUM_RRS)
116 | return OMG_DNS_ENOMEM;
117 |
118 | rrs->ret[rrs->rr_idx] = ret;
119 | if (rr)
120 | rrs->rr[rrs->rr_idx] = *rr;
121 | rrs->rr_idx++;
122 | if (rrs->rr_idx != NUM_RRS)
123 | rrs->label_idx[rrs->rr_idx] = rrs->labels->label_idx;
124 |
125 | return OMG_DNS_OK;
126 | }
127 |
128 | static void parse(uint8_t* data, size_t len)
129 | {
130 | omg_dns_t dns = OMG_DNS_T_INIT;
131 | int ret;
132 | struct rrs rrs = { 0, 0, 0 };
133 | struct labels labels = { 0, 0, 0 };
134 | size_t n;
135 |
136 | rrs.rr = calloc(NUM_RRS, sizeof(omg_dns_rr_t));
137 | rrs.ret = calloc(NUM_RRS, sizeof(int));
138 | rrs.label_idx = calloc(NUM_RRS, sizeof(size_t));
139 | rrs.labels = &labels;
140 |
141 | labels.data = data;
142 | labels.label = calloc(NUM_LABELS, sizeof(omg_dns_label_t));
143 |
144 | omg_dns_set_rr_callback(&dns, rr_callback, (void*)&rrs);
145 | omg_dns_set_label_callback(&dns, label_callback, (void*)&labels);
146 | ret = omg_dns_parse(&dns, data, len);
147 |
148 | if (omg_dns_have_id(&dns))
149 | printf("id: %u\n", omg_dns_id(&dns));
150 | if (omg_dns_have_qr(&dns))
151 | printf(" qr: %u\n", omg_dns_qr(&dns));
152 | if (omg_dns_have_opcode(&dns))
153 | printf(" opcode: %u\n", omg_dns_opcode(&dns));
154 | if (omg_dns_have_aa(&dns))
155 | printf(" aa: %u\n", omg_dns_aa(&dns));
156 | if (omg_dns_have_tc(&dns))
157 | printf(" tc: %u\n", omg_dns_tc(&dns));
158 | if (omg_dns_have_rd(&dns))
159 | printf(" rd: %u\n", omg_dns_rd(&dns));
160 | if (omg_dns_have_ra(&dns))
161 | printf(" ra: %u\n", omg_dns_ra(&dns));
162 | if (omg_dns_have_z(&dns))
163 | printf(" z: %u\n", omg_dns_z(&dns));
164 | if (omg_dns_have_ad(&dns))
165 | printf(" ad: %u\n", omg_dns_ad(&dns));
166 | if (omg_dns_have_cd(&dns))
167 | printf(" cd: %u\n", omg_dns_cd(&dns));
168 | if (omg_dns_have_rcode(&dns))
169 | printf(" rcode: %u\n", omg_dns_rcode(&dns));
170 |
171 | if (omg_dns_have_qdcount(&dns))
172 | printf(" qdcount: %u\n", omg_dns_qdcount(&dns));
173 | if (omg_dns_have_ancount(&dns))
174 | printf(" ancount: %u\n", omg_dns_ancount(&dns));
175 | if (omg_dns_have_nscount(&dns))
176 | printf(" nscount: %u\n", omg_dns_nscount(&dns));
177 | if (omg_dns_have_arcount(&dns))
178 | printf(" arcount: %u\n", omg_dns_arcount(&dns));
179 |
180 | if (omg_dns_have_questions(&dns))
181 | printf(" questions: %lu\n", omg_dns_questions(&dns));
182 | if (omg_dns_have_answers(&dns))
183 | printf(" answers: %lu\n", omg_dns_answers(&dns));
184 | if (omg_dns_have_authorities(&dns))
185 | printf(" authorities: %lu\n", omg_dns_authorities(&dns));
186 | if (omg_dns_have_additionals(&dns))
187 | printf(" additionals: %lu\n", omg_dns_additionals(&dns));
188 |
189 | if (print_labels) {
190 | printf(" labels:\n");
191 | for (n = 0; n < labels.label_idx; n++) {
192 | print_label(&(labels.label[n]), data, " ");
193 | }
194 | }
195 |
196 | for (n = 0; n < rrs.rr_idx; n++) {
197 | omg_dns_rr_t* rr = &(rrs.rr[n]);
198 |
199 | printf(" rr %lu\n", n);
200 |
201 | if (omg_dns_rr_have_labels(rr))
202 | printf(" labels: %lu\n", omg_dns_rr_labels(rr));
203 |
204 | if (omg_dns_rr_labels(rr)) {
205 | size_t l = rrs.label_idx[n];
206 | size_t loop = 0;
207 |
208 | printf(" label:");
209 | while (!omg_dns_label_is_end(&(labels.label[l]))) {
210 | if (!omg_dns_label_is_complete(&(labels.label[l]))) {
211 | printf(" ");
212 | break;
213 | }
214 |
215 | if (loop > labels.label_idx) {
216 | printf(" ");
217 | break;
218 | }
219 | loop++;
220 |
221 | if (omg_dns_label_have_offset(&(labels.label[l]))) {
222 | size_t l2;
223 |
224 | for (l2 = 0; l2 < labels.label_idx; l2++) {
225 | if (omg_dns_label_have_dn(&(labels.label[l2]))
226 | && omg_dns_label_offset(&(labels.label[l2])) == omg_dns_label_offset(&(labels.label[l]))) {
227 | l = l2;
228 | break;
229 | }
230 | }
231 | if (l2 < labels.label_idx) {
232 | printf(" ");
233 | continue;
234 | }
235 | printf(" ");
236 | break;
237 | } else if (omg_dns_label_have_extension_bits(&(labels.label[l]))) {
238 | printf(" ");
239 | break;
240 | } else if (omg_dns_label_have_dn(&(labels.label[l]))) {
241 | uint8_t* dn = data + omg_dns_label_dn_offset(&(labels.label[l]));
242 | size_t dnlen = omg_dns_label_length(&(labels.label[l]));
243 |
244 | printf(" ");
245 | while (dnlen--) {
246 | printf("%c", *dn++);
247 | }
248 | printf(" .");
249 | l++;
250 | } else {
251 | printf("");
252 | break;
253 | }
254 | }
255 | printf("\n");
256 | }
257 |
258 | printf(" question: %s\n", omg_dns_rr_is_question(rr) ? "yes" : "no");
259 |
260 | if (omg_dns_rr_have_type(rr))
261 | printf(" type: %u\n", omg_dns_rr_type(rr));
262 | if (omg_dns_rr_have_class(rr))
263 | printf(" class: %u\n", omg_dns_rr_class(rr));
264 | if (omg_dns_rr_have_ttl(rr))
265 | printf(" ttl: %u\n", omg_dns_rr_ttl(rr));
266 | if (omg_dns_rr_have_rdlength(rr))
267 | printf(" rdlength: %u\n", omg_dns_rr_rdlength(rr));
268 | if (omg_dns_rr_have_rdata(rr)) {
269 | uint8_t* rdata = data + omg_dns_rr_rdata_offset(rr);
270 | size_t rdatalen = omg_dns_rr_rdlength(rr);
271 |
272 | printf(" rdata: 0x");
273 | while (rdatalen--) {
274 | printf("%02x", *rdata++);
275 | }
276 | printf("\n");
277 | }
278 |
279 | if (omg_dns_rr_have_rdata_labels(rr))
280 | printf(" rdata labels: %lu\n", omg_dns_rr_rdata_labels(rr));
281 |
282 | if (omg_dns_rr_rdata_labels(rr)) {
283 | size_t rl = omg_dns_rr_num_rdata_labels(rr);
284 | size_t last = 0;
285 |
286 | while (rl--) {
287 | size_t l = rrs.label_idx[n] + omg_dns_rr_labels(rr) + last;
288 | size_t loop = 0;
289 | unsigned short jumped = 0;
290 |
291 | printf(" rdata label:");
292 | while (!omg_dns_label_is_end(&(labels.label[l]))) {
293 | if (!jumped)
294 | last++;
295 |
296 | if (!omg_dns_label_is_complete(&(labels.label[l]))) {
297 | printf(" ");
298 | break;
299 | }
300 |
301 | if (loop > labels.label_idx) {
302 | printf(" ");
303 | break;
304 | }
305 | loop++;
306 |
307 | if (omg_dns_label_have_offset(&(labels.label[l]))) {
308 | size_t l2;
309 |
310 | for (l2 = 0; l2 < labels.label_idx; l2++) {
311 | if (omg_dns_label_have_dn(&(labels.label[l2]))
312 | && omg_dns_label_offset(&(labels.label[l2])) == omg_dns_label_offset(&(labels.label[l]))) {
313 | l = l2;
314 | break;
315 | }
316 | }
317 | if (l2 < labels.label_idx) {
318 | jumped = 1;
319 | printf(" ");
320 | continue;
321 | }
322 | printf(" ");
323 | break;
324 | } else if (omg_dns_label_have_extension_bits(&(labels.label[l]))) {
325 | printf(" ");
326 | break;
327 | } else if (omg_dns_label_have_dn(&(labels.label[l]))) {
328 | uint8_t* dn = data + omg_dns_label_dn_offset(&(labels.label[l]));
329 | size_t dnlen = omg_dns_label_length(&(labels.label[l]));
330 |
331 | printf(" ");
332 | while (dnlen--) {
333 | printf("%c", *dn++);
334 | }
335 | printf(" .");
336 | l++;
337 | } else {
338 | printf("");
339 | break;
340 | }
341 | }
342 | printf("\n");
343 | }
344 | }
345 |
346 | if (omg_dns_rr_have_padding(rr)) {
347 | uint8_t* pad = data + omg_dns_rr_padding_offset(rr);
348 | size_t padlen = omg_dns_rr_padding_length(rr);
349 |
350 | printf(" padding: 0x");
351 | while (padlen--) {
352 | printf("%02x", *pad++);
353 | }
354 | printf("\n");
355 | }
356 |
357 | printf(" complete: %s\n", omg_dns_rr_is_complete(rr) ? "yes" : "no");
358 | printf(" ret: %d\n", rrs.ret[n]);
359 | }
360 |
361 | if (omg_dns_have_padding(&dns)) {
362 | uint8_t* pad = data + omg_dns_padding_offset(&dns);
363 | size_t padlen = omg_dns_padding_length(&dns);
364 |
365 | printf(" padding: 0x");
366 | while (padlen--) {
367 | printf("%02x", *pad++);
368 | }
369 | printf("\n");
370 | }
371 |
372 | printf(" complete: %s\n", omg_dns_is_complete(&dns) ? "yes" : "no");
373 | printf(" ret: %d\n", ret);
374 |
375 | free(rrs.rr);
376 | free(rrs.ret);
377 | free(rrs.label_idx);
378 | free(labels.label);
379 | }
380 |
381 | int main(int argc, char** argv)
382 | {
383 | int opt, err = 0;
384 | uint8_t dns[64 * 1024];
385 |
386 | while ((opt = getopt(argc, argv, "lhV")) != -1) {
387 | switch (opt) {
388 | case 'l':
389 | print_labels = 1;
390 | break;
391 |
392 | case 'h':
393 | printf(
394 | "usage: hexdns2text [options] \n"
395 | " -l also print a list of all labels\n"
396 | " -V display version and exit\n"
397 | " -h this\n");
398 | exit(0);
399 |
400 | case 'V':
401 | printf("hexdns2text version %s (omg_dns version %s)\n",
402 | PACKAGE_VERSION,
403 | OMG_DNS_VERSION_STR);
404 | exit(0);
405 |
406 | default:
407 | err = -1;
408 | }
409 | }
410 |
411 | /*
412 | if (err == -2) { // lgtm [cpp/constant-comparison]
413 | fprintf(stderr, "Unsupported argument(s)\n");
414 | exit(1);
415 | }
416 | */
417 | if (err == -1) {
418 | fprintf(stderr, "Invalid argument(s)\n");
419 | exit(1);
420 | }
421 |
422 | while (optind < argc) {
423 | size_t len = strlen(argv[optind]), n;
424 | char* hex = argv[optind];
425 | uint8_t* byte = dns;
426 | int high, low;
427 |
428 | if (len % 2) {
429 | fprintf(stderr, "Invalid HEX, odd number of characters\n");
430 | exit(2);
431 | }
432 | if ((len / 2) > sizeof(dns)) {
433 | fprintf(stderr, "Invalid HEX, too large\n");
434 | exit(2);
435 | }
436 |
437 | memset(dns, 0, sizeof(dns));
438 | n = len;
439 | while (n) {
440 | if ((high = hex2byte(*hex)) < 0) {
441 | fprintf(stderr, "Invalid HEX, %c not a valid HEX character\n", *hex);
442 | exit(2);
443 | }
444 | hex++;
445 | if ((low = hex2byte(*hex)) < 0) {
446 | fprintf(stderr, "Invalid HEX, %c not a valid HEX character\n", *hex);
447 | exit(2);
448 | }
449 | hex++;
450 |
451 | *byte = (high << 4) | low;
452 | byte++;
453 | n -= 2;
454 | }
455 |
456 | parse(dns, len / 2);
457 |
458 | optind++;
459 | }
460 |
461 | return 0;
462 | }
463 |
--------------------------------------------------------------------------------
/hexdns2text/test/Makefile.am:
--------------------------------------------------------------------------------
1 | # Author Jerry Lundström
2 | # Copyright (c) 2017, OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of omg-dns.
6 | #
7 | # omg-dns is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU Lesser General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # omg-dns is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public License
18 | # along with omg-dns. If not, see .
19 |
20 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
21 |
22 | CLEANFILES = test1.out test2.out
23 |
24 | TESTS = test1.sh test2.sh
25 |
26 | EXTRA_DIST = $(TESTS) \
27 | test1.gold test2.gold
28 |
--------------------------------------------------------------------------------
/hexdns2text/test/test1.gold:
--------------------------------------------------------------------------------
1 | id: 20724
2 | qr: 0
3 | opcode: 0
4 | aa: 0
5 | tc: 0
6 | rd: 1
7 | ra: 0
8 | z: 0
9 | ad: 0
10 | cd: 0
11 | rcode: 0
12 | qdcount: 1
13 | ancount: 0
14 | nscount: 0
15 | arcount: 0
16 | questions: 1
17 | answers: 0
18 | authorities: 0
19 | additionals: 0
20 | rr 0
21 | labels: 2
22 | label: google . com .
23 | question: yes
24 | type: 1
25 | class: 1
26 | complete: yes
27 | ret: 0
28 | complete: yes
29 | ret: 0
30 | id: 20724
31 | qr: 1
32 | opcode: 0
33 | aa: 0
34 | tc: 0
35 | rd: 1
36 | ra: 1
37 | z: 0
38 | ad: 0
39 | cd: 0
40 | rcode: 0
41 | qdcount: 1
42 | ancount: 1
43 | nscount: 0
44 | arcount: 0
45 | questions: 1
46 | answers: 1
47 | authorities: 0
48 | additionals: 0
49 | rr 0
50 | labels: 2
51 | label: google . com .
52 | question: yes
53 | type: 1
54 | class: 1
55 | complete: yes
56 | ret: 0
57 | rr 1
58 | labels: 1
59 | label: google . com .
60 | question: no
61 | type: 1
62 | class: 1
63 | ttl: 21
64 | rdlength: 4
65 | rdata: 0xacd916ae
66 | complete: yes
67 | ret: 0
68 | complete: yes
69 | ret: 0
70 | id: 28919
71 | qr: 1
72 | opcode: 0
73 | aa: 0
74 | tc: 0
75 | rd: 1
76 | ra: 1
77 | z: 0
78 | ad: 0
79 | cd: 0
80 | rcode: 0
81 | qdcount: 1
82 | ancount: 1
83 | nscount: 0
84 | arcount: 0
85 | questions: 1
86 | answers: 1
87 | authorities: 0
88 | additionals: 0
89 | rr 0
90 | labels: 2
91 | label: google . com .
92 | question: yes
93 | type: 6
94 | class: 1
95 | complete: yes
96 | ret: 0
97 | rr 1
98 | labels: 1
99 | label: google . com .
100 | question: no
101 | type: 6
102 | class: 1
103 | ttl: 59
104 | rdlength: 38
105 | rdata: 0x036e7333c00c09646e732d61646d696ec00c08a155200000038400000384000007080000003c
106 | rdata labels: 4
107 | rdata label: ns3 . google . com .
108 | rdata label: dns-admin . google . com .
109 | complete: yes
110 | ret: 0
111 | complete: yes
112 | ret: 0
113 |
--------------------------------------------------------------------------------
/hexdns2text/test/test1.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -xe
2 | #
3 | # Author Jerry Lundström
4 | # Copyright (c) 2017, OARC, Inc.
5 | # All rights reserved.
6 | #
7 | # This file is part of omg-dns.
8 | #
9 | # omg-dns is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU Lesser General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # omg-dns is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU Lesser General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU Lesser General Public License
20 | # along with omg-dns. If not, see .
21 |
22 | ../hexdns2text \
23 | 50f40100000100000000000006676f6f676c6503636f6d0000010001 \
24 | 50f48180000100010000000006676f6f676c6503636f6d0000010001c00c00010001000000150004acd916ae \
25 | 70f78180000100010000000006676f6f676c6503636f6d0000060001c00c000600010000003b0026036e7333c00c09646e732d61646d696ec00c08a155200000038400000384000007080000003c \
26 | > test1.out
27 |
28 | diff test1.out "$srcdir/test1.gold"
29 |
--------------------------------------------------------------------------------
/hexdns2text/test/test2.gold:
--------------------------------------------------------------------------------
1 | id: 1614
2 | qr: 1
3 | opcode: 0
4 | aa: 0
5 | tc: 0
6 | rd: 1
7 | ra: 1
8 | z: 0
9 | ad: 0
10 | cd: 0
11 | rcode: 0
12 | qdcount: 1
13 | ancount: 11
14 | nscount: 4
15 | arcount: 5
16 | questions: 1
17 | answers: 11
18 | authorities: 4
19 | additionals: 5
20 | rr 0
21 | labels: 2
22 | label: google . com .
23 | question: yes
24 | type: 1
25 | class: 1
26 | complete: yes
27 | ret: 0
28 | rr 1
29 | labels: 1
30 | label: google . com .
31 | question: no
32 | type: 1
33 | class: 1
34 | ttl: 5
35 | rdlength: 4
36 | rdata: 0xadc22986
37 | complete: yes
38 | ret: 0
39 | rr 2
40 | labels: 1
41 | label: google . com .
42 | question: no
43 | type: 1
44 | class: 1
45 | ttl: 5
46 | rdlength: 4
47 | rdata: 0xadc22987
48 | complete: yes
49 | ret: 0
50 | rr 3
51 | labels: 1
52 | label: google . com .
53 | question: no
54 | type: 1
55 | class: 1
56 | ttl: 5
57 | rdlength: 4
58 | rdata: 0xadc22988
59 | complete: yes
60 | ret: 0
61 | rr 4
62 | labels: 1
63 | label: google . com .
64 | question: no
65 | type: 1
66 | class: 1
67 | ttl: 5
68 | rdlength: 4
69 | rdata: 0xadc22989
70 | complete: yes
71 | ret: 0
72 | rr 5
73 | labels: 1
74 | label: google . com .
75 | question: no
76 | type: 1
77 | class: 1
78 | ttl: 5
79 | rdlength: 4
80 | rdata: 0xadc2298e
81 | complete: yes
82 | ret: 0
83 | rr 6
84 | labels: 1
85 | label: google . com .
86 | question: no
87 | type: 1
88 | class: 1
89 | ttl: 5
90 | rdlength: 4
91 | rdata: 0xadc22980
92 | complete: yes
93 | ret: 0
94 | rr 7
95 | labels: 1
96 | label: google . com .
97 | question: no
98 | type: 1
99 | class: 1
100 | ttl: 5
101 | rdlength: 4
102 | rdata: 0xadc22981
103 | complete: yes
104 | ret: 0
105 | rr 8
106 | labels: 1
107 | label: google . com .
108 | question: no
109 | type: 1
110 | class: 1
111 | ttl: 5
112 | rdlength: 4
113 | rdata: 0xadc22982
114 | complete: yes
115 | ret: 0
116 | rr 9
117 | labels: 1
118 | label: google . com .
119 | question: no
120 | type: 1
121 | class: 1
122 | ttl: 5
123 | rdlength: 4
124 | rdata: 0xadc22983
125 | complete: yes
126 | ret: 0
127 | rr 10
128 | labels: 1
129 | label: google . com .
130 | question: no
131 | type: 1
132 | class: 1
133 | ttl: 5
134 | rdlength: 4
135 | rdata: 0xadc22984
136 | complete: yes
137 | ret: 0
138 | rr 11
139 | labels: 1
140 | label: google . com .
141 | question: no
142 | type: 1
143 | class: 1
144 | ttl: 5
145 | rdlength: 4
146 | rdata: 0xadc22985
147 | complete: yes
148 | ret: 0
149 | rr 12
150 | labels: 1
151 | label: google . com .
152 | question: no
153 | type: 2
154 | class: 1
155 | ttl: 5
156 | rdlength: 6
157 | rdata: 0x036e7331c00c
158 | rdata labels: 2
159 | rdata label: ns1 . google . com .
160 | complete: yes
161 | ret: 0
162 | rr 13
163 | labels: 1
164 | label: google . com .
165 | question: no
166 | type: 2
167 | class: 1
168 | ttl: 5
169 | rdlength: 6
170 | rdata: 0x036e7332c00c
171 | rdata labels: 2
172 | rdata label: ns2 . google . com .
173 | complete: yes
174 | ret: 0
175 | rr 14
176 | labels: 1
177 | label: google . com .
178 | question: no
179 | type: 2
180 | class: 1
181 | ttl: 5
182 | rdlength: 6
183 | rdata: 0x036e7333c00c
184 | rdata labels: 2
185 | rdata label: ns3 . google . com .
186 | complete: yes
187 | ret: 0
188 | rr 15
189 | labels: 1
190 | label: google . com .
191 | question: no
192 | type: 2
193 | class: 1
194 | ttl: 5
195 | rdlength: 6
196 | rdata: 0x036e7334c00c
197 | rdata labels: 2
198 | rdata label: ns4 . google . com .
199 | complete: yes
200 | ret: 0
201 | rr 16
202 | labels: 1
203 | label: ns1 . google . com .
204 | question: no
205 | type: 1
206 | class: 1
207 | ttl: 5
208 | rdlength: 4
209 | rdata: 0xd8ef200a
210 | complete: yes
211 | ret: 0
212 | rr 17
213 | labels: 1
214 | label: ns2 . google . com .
215 | question: no
216 | type: 1
217 | class: 1
218 | ttl: 5
219 | rdlength: 4
220 | rdata: 0xd8ef220a
221 | complete: yes
222 | ret: 0
223 | rr 18
224 | labels: 1
225 | label: ns3 . google . com .
226 | question: no
227 | type: 1
228 | class: 1
229 | ttl: 5
230 | rdlength: 4
231 | rdata: 0xd8ef240a
232 | complete: yes
233 | ret: 0
234 | rr 19
235 | labels: 1
236 | label: ns4 . google . com .
237 | question: no
238 | type: 1
239 | class: 1
240 | ttl: 5
241 | rdlength: 4
242 | rdata: 0xd8ef260a
243 | complete: yes
244 | ret: 0
245 | rr 20
246 | labels: 0
247 | question: no
248 | type: 41
249 | class: 1280
250 | ttl: 5
251 | rdlength: 0
252 | rdata: 0x
253 | complete: yes
254 | ret: 0
255 | complete: yes
256 | ret: 0
257 | id: 28129
258 | qr: 1
259 | opcode: 0
260 | aa: 0
261 | tc: 0
262 | rd: 1
263 | ra: 1
264 | z: 0
265 | ad: 0
266 | cd: 0
267 | rcode: 0
268 | qdcount: 1
269 | ancount: 4
270 | nscount: 10
271 | arcount: 8
272 | questions: 1
273 | answers: 4
274 | authorities: 10
275 | additionals: 8
276 | rr 0
277 | labels: 2
278 | label: amazon . com .
279 | question: yes
280 | type: 1
281 | class: 1
282 | complete: yes
283 | ret: 0
284 | rr 1
285 | labels: 1
286 | label: amazon . com .
287 | question: no
288 | type: 1
289 | class: 1
290 | ttl: 5
291 | rdlength: 4
292 | rdata: 0x4815c2d4
293 | complete: yes
294 | ret: 0
295 | rr 2
296 | labels: 1
297 | label: amazon . com .
298 | question: no
299 | type: 1
300 | class: 1
301 | ttl: 5
302 | rdlength: 4
303 | rdata: 0x4815d7e8
304 | complete: yes
305 | ret: 0
306 | rr 3
307 | labels: 1
308 | label: amazon . com .
309 | question: no
310 | type: 1
311 | class: 1
312 | ttl: 5
313 | rdlength: 4
314 | rdata: 0xb02062a6
315 | complete: yes
316 | ret: 0
317 | rr 4
318 | labels: 1
319 | label: amazon . com .
320 | question: no
321 | type: 1
322 | class: 1
323 | ttl: 5
324 | rdlength: 4
325 | rdata: 0xcdfbf236
326 | complete: yes
327 | ret: 0
328 | rr 5
329 | labels: 1
330 | label: amazon . com .
331 | question: no
332 | type: 2
333 | class: 1
334 | ttl: 5
335 | rdlength: 20
336 | rdata: 0x0570646e733408756c747261646e73036f726700
337 | rdata labels: 3
338 | rdata label: pdns4 . ultradns . org .
339 | complete: yes
340 | ret: 0
341 | rr 6
342 | labels: 1
343 | label: amazon . com .
344 | question: no
345 | type: 2
346 | class: 1
347 | ttl: 5
348 | rdlength: 21
349 | rdata: 0x0570646e733508756c747261646e7304696e666f00
350 | rdata labels: 3
351 | rdata label: pdns5 . ultradns . info .
352 | complete: yes
353 | ret: 0
354 | rr 7
355 | labels: 1
356 | label: amazon . com .
357 | question: no
358 | type: 2
359 | class: 1
360 | ttl: 5
361 | rdlength: 22
362 | rdata: 0x0570646e733608756c747261646e7302636f02756b00
363 | rdata labels: 4
364 | rdata label: pdns6 . ultradns . co . uk .
365 | complete: yes
366 | ret: 0
367 | rr 8
368 | labels: 1
369 | label: amazon . com .
370 | question: no
371 | type: 2
372 | class: 1
373 | ttl: 5
374 | rdlength: 20
375 | rdata: 0x036e7331037033310664796e656374036e657400
376 | rdata labels: 4
377 | rdata label: ns1 . p31 . dynect . net .
378 | complete: yes
379 | ret: 0
380 | rr 9
381 | labels: 1
382 | label: amazon . com .
383 | question: no
384 | type: 2
385 | class: 1
386 | ttl: 5
387 | rdlength: 6
388 | rdata: 0x036e7332c0cf
389 | rdata labels: 2
390 | rdata label: ns2 . p31 . dynect . net .
391 | complete: yes
392 | ret: 0
393 | rr 10
394 | labels: 1
395 | label: amazon . com .
396 | question: no
397 | type: 2
398 | class: 1
399 | ttl: 5
400 | rdlength: 6
401 | rdata: 0x036e7333c0cf
402 | rdata labels: 2
403 | rdata label: ns3 . p31 . dynect . net .
404 | complete: yes
405 | ret: 0
406 | rr 11
407 | labels: 1
408 | label: amazon . com .
409 | question: no
410 | type: 2
411 | class: 1
412 | ttl: 5
413 | rdlength: 6
414 | rdata: 0x036e7334c0cf
415 | rdata labels: 2
416 | rdata label: ns4 . p31 . dynect . net .
417 | complete: yes
418 | ret: 0
419 | rr 12
420 | labels: 1
421 | label: amazon . com .
422 | question: no
423 | type: 2
424 | class: 1
425 | ttl: 5
426 | rdlength: 17
427 | rdata: 0x0570646e733108756c747261646e73c0da
428 | rdata labels: 3
429 | rdata label: pdns1 . ultradns . net .
430 | complete: yes
431 | ret: 0
432 | rr 13
433 | labels: 1
434 | label: amazon . com .
435 | question: no
436 | type: 2
437 | class: 1
438 | ttl: 5
439 | rdlength: 8
440 | rdata: 0x0570646e7332c127
441 | rdata labels: 2
442 | rdata label: pdns2 . ultradns . net .
443 | complete: yes
444 | ret: 0
445 | rr 14
446 | labels: 1
447 | label: amazon . com .
448 | question: no
449 | type: 2
450 | class: 1
451 | ttl: 5
452 | rdlength: 8
453 | rdata: 0x0570646e7333c06e
454 | rdata labels: 2
455 | rdata label: pdns3 . ultradns . org .
456 | complete: yes
457 | ret: 0
458 | rr 15
459 | labels: 1
460 | label: ns1 . p31 . dynect . net .
461 | question: no
462 | type: 1
463 | class: 1
464 | ttl: 5
465 | rdlength: 4
466 | rdata: 0xd04e461f
467 | complete: yes
468 | ret: 0
469 | rr 16
470 | labels: 1
471 | label: ns2 . p31 . dynect . net .
472 | question: no
473 | type: 1
474 | class: 1
475 | ttl: 5
476 | rdlength: 4
477 | rdata: 0xcc0dfa1f
478 | complete: yes
479 | ret: 0
480 | rr 17
481 | labels: 1
482 | label: ns3 . p31 . dynect . net .
483 | question: no
484 | type: 1
485 | class: 1
486 | ttl: 5
487 | rdlength: 4
488 | rdata: 0xd04e471f
489 | complete: yes
490 | ret: 0
491 | rr 18
492 | labels: 1
493 | label: ns4 . p31 . dynect . net .
494 | question: no
495 | type: 1
496 | class: 1
497 | ttl: 5
498 | rdlength: 4
499 | rdata: 0xcc0dfb1f
500 | complete: yes
501 | ret: 0
502 | rr 19
503 | labels: 1
504 | label: pdns1 . ultradns . net .
505 | question: no
506 | type: 1
507 | class: 1
508 | ttl: 5
509 | rdlength: 4
510 | rdata: 0xcc4a6c01
511 | complete: yes
512 | ret: 0
513 | rr 20
514 | labels: 1
515 | label: pdns1 . ultradns . net .
516 | question: no
517 | type: 28
518 | class: 1
519 | ttl: 5
520 | rdlength: 16
521 | rdata: 0x20010502f3ff00000000000000000001
522 | complete: yes
523 | ret: 0
524 | rr 21
525 | labels: 1
526 | label: pdns2 . ultradns . net .
527 | question: no
528 | type: 1
529 | class: 1
530 | ttl: 5
531 | rdlength: 4
532 | rdata: 0xcc4a6d01
533 | complete: yes
534 | ret: 0
535 | rr 22
536 | labels: 1
537 | label: pdns2 . ultradns . net .
538 | question: no
539 | type: 28
540 | class: 1
541 | ttl: 5
542 | rdlength: 16
543 | rdata: 0x261000a1101400000000000000000001
544 | complete: yes
545 | ret: 0
546 | complete: yes
547 | ret: 0
548 | id: 64557
549 | qr: 1
550 | opcode: 0
551 | aa: 0
552 | tc: 0
553 | rd: 1
554 | ra: 1
555 | z: 0
556 | ad: 0
557 | cd: 0
558 | rcode: 0
559 | qdcount: 1
560 | ancount: 3
561 | nscount: 7
562 | arcount: 8
563 | questions: 1
564 | answers: 3
565 | authorities: 7
566 | additionals: 8
567 | rr 0
568 | labels: 2
569 | label: yahoo . com .
570 | question: yes
571 | type: 1
572 | class: 1
573 | complete: yes
574 | ret: 0
575 | rr 1
576 | labels: 1
577 | label: yahoo . com .
578 | question: no
579 | type: 1
580 | class: 1
581 | ttl: 5
582 | rdlength: 4
583 | rdata: 0x628afd6d
584 | complete: yes
585 | ret: 0
586 | rr 2
587 | labels: 1
588 | label: yahoo . com .
589 | question: no
590 | type: 1
591 | class: 1
592 | ttl: 5
593 | rdlength: 4
594 | rdata: 0x628bb718
595 | complete: yes
596 | ret: 0
597 | rr 3
598 | labels: 1
599 | label: yahoo . com .
600 | question: no
601 | type: 1
602 | class: 1
603 | ttl: 5
604 | rdlength: 4
605 | rdata: 0xcebe242d
606 | complete: yes
607 | ret: 0
608 | rr 4
609 | labels: 1
610 | label: yahoo . com .
611 | question: no
612 | type: 2
613 | class: 1
614 | ttl: 5
615 | rdlength: 6
616 | rdata: 0x036e7336c00c
617 | rdata labels: 2
618 | rdata label: ns6 . yahoo . com .
619 | complete: yes
620 | ret: 0
621 | rr 5
622 | labels: 1
623 | label: yahoo . com .
624 | question: no
625 | type: 2
626 | class: 1
627 | ttl: 5
628 | rdlength: 6
629 | rdata: 0x036e7338c00c
630 | rdata labels: 2
631 | rdata label: ns8 . yahoo . com .
632 | complete: yes
633 | ret: 0
634 | rr 6
635 | labels: 1
636 | label: yahoo . com .
637 | question: no
638 | type: 2
639 | class: 1
640 | ttl: 5
641 | rdlength: 6
642 | rdata: 0x036e7331c00c
643 | rdata labels: 2
644 | rdata label: ns1 . yahoo . com .
645 | complete: yes
646 | ret: 0
647 | rr 7
648 | labels: 1
649 | label: yahoo . com .
650 | question: no
651 | type: 2
652 | class: 1
653 | ttl: 5
654 | rdlength: 6
655 | rdata: 0x036e7332c00c
656 | rdata labels: 2
657 | rdata label: ns2 . yahoo . com .
658 | complete: yes
659 | ret: 0
660 | rr 8
661 | labels: 1
662 | label: yahoo . com .
663 | question: no
664 | type: 2
665 | class: 1
666 | ttl: 5
667 | rdlength: 6
668 | rdata: 0x036e7333c00c
669 | rdata labels: 2
670 | rdata label: ns3 . yahoo . com .
671 | complete: yes
672 | ret: 0
673 | rr 9
674 | labels: 1
675 | label: yahoo . com .
676 | question: no
677 | type: 2
678 | class: 1
679 | ttl: 5
680 | rdlength: 6
681 | rdata: 0x036e7334c00c
682 | rdata labels: 2
683 | rdata label: ns4 . yahoo . com .
684 | complete: yes
685 | ret: 0
686 | rr 10
687 | labels: 1
688 | label: yahoo . com .
689 | question: no
690 | type: 2
691 | class: 1
692 | ttl: 5
693 | rdlength: 6
694 | rdata: 0x036e7335c00c
695 | rdata labels: 2
696 | rdata label: ns5 . yahoo . com .
697 | complete: yes
698 | ret: 0
699 | rr 11
700 | labels: 1
701 | label: ns1 . yahoo . com .
702 | question: no
703 | type: 1
704 | class: 1
705 | ttl: 5
706 | rdlength: 4
707 | rdata: 0x44b48310
708 | complete: yes
709 | ret: 0
710 | rr 12
711 | labels: 1
712 | label: ns2 . yahoo . com .
713 | question: no
714 | type: 1
715 | class: 1
716 | ttl: 5
717 | rdlength: 4
718 | rdata: 0x448eff10
719 | complete: yes
720 | ret: 0
721 | rr 13
722 | labels: 1
723 | label: ns3 . yahoo . com .
724 | question: no
725 | type: 1
726 | class: 1
727 | ttl: 5
728 | rdlength: 4
729 | rdata: 0xcb54dd35
730 | complete: yes
731 | ret: 0
732 | rr 14
733 | labels: 1
734 | label: ns4 . yahoo . com .
735 | question: no
736 | type: 1
737 | class: 1
738 | ttl: 5
739 | rdlength: 4
740 | rdata: 0x628a0b9d
741 | complete: yes
742 | ret: 0
743 | rr 15
744 | labels: 1
745 | label: ns5 . yahoo . com .
746 | question: no
747 | type: 1
748 | class: 1
749 | ttl: 5
750 | rdlength: 4
751 | rdata: 0x77a0f77c
752 | complete: yes
753 | ret: 0
754 | rr 16
755 | labels: 1
756 | label: ns6 . yahoo . com .
757 | question: no
758 | type: 1
759 | class: 1
760 | ttl: 5
761 | rdlength: 4
762 | rdata: 0xca2bdfaa
763 | complete: yes
764 | ret: 0
765 | rr 17
766 | labels: 1
767 | label: ns8 . yahoo . com .
768 | question: no
769 | type: 1
770 | class: 1
771 | ttl: 5
772 | rdlength: 4
773 | rdata: 0xcaa56816
774 | complete: yes
775 | ret: 0
776 | rr 18
777 | labels: 0
778 | question: no
779 | type: 41
780 | class: 1280
781 | ttl: 5
782 | rdlength: 0
783 | rdata: 0x
784 | complete: yes
785 | ret: 0
786 | complete: yes
787 | ret: 0
788 | id: 62518
789 | qr: 1
790 | opcode: 0
791 | aa: 0
792 | tc: 0
793 | rd: 1
794 | ra: 1
795 | z: 0
796 | ad: 0
797 | cd: 0
798 | rcode: 0
799 | qdcount: 1
800 | ancount: 2
801 | nscount: 5
802 | arcount: 11
803 | questions: 1
804 | answers: 2
805 | authorities: 5
806 | additionals: 11
807 | rr 0
808 | labels: 2
809 | label: microsoft . com .
810 | question: yes
811 | type: 1
812 | class: 1
813 | complete: yes
814 | ret: 0
815 | rr 1
816 | labels: 1
817 | label: microsoft . com .
818 | question: no
819 | type: 1
820 | class: 1
821 | ttl: 5
822 | rdlength: 4
823 | rdata: 0x40040b25
824 | complete: yes
825 | ret: 0
826 | rr 2
827 | labels: 1
828 | label: microsoft . com .
829 | question: no
830 | type: 1
831 | class: 1
832 | ttl: 5
833 | rdlength: 4
834 | rdata: 0x41373ac9
835 | complete: yes
836 | ret: 0
837 | rr 3
838 | labels: 1
839 | label: microsoft . com .
840 | question: no
841 | type: 2
842 | class: 1
843 | ttl: 5
844 | rdlength: 14
845 | rdata: 0x036e7331046d736674036e657400
846 | rdata labels: 3
847 | rdata label: ns1 . msft . net .
848 | complete: yes
849 | ret: 0
850 | rr 4
851 | labels: 1
852 | label: microsoft . com .
853 | question: no
854 | type: 2
855 | class: 1
856 | ttl: 5
857 | rdlength: 6
858 | rdata: 0x036e7332c04f
859 | rdata labels: 2
860 | rdata label: ns2 . msft . net .
861 | complete: yes
862 | ret: 0
863 | rr 5
864 | labels: 1
865 | label: microsoft . com .
866 | question: no
867 | type: 2
868 | class: 1
869 | ttl: 5
870 | rdlength: 6
871 | rdata: 0x036e7333c04f
872 | rdata labels: 2
873 | rdata label: ns3 . msft . net .
874 | complete: yes
875 | ret: 0
876 | rr 6
877 | labels: 1
878 | label: microsoft . com .
879 | question: no
880 | type: 2
881 | class: 1
882 | ttl: 5
883 | rdlength: 6
884 | rdata: 0x036e7334c04f
885 | rdata labels: 2
886 | rdata label: ns4 . msft . net .
887 | complete: yes
888 | ret: 0
889 | rr 7
890 | labels: 1
891 | label: microsoft . com .
892 | question: no
893 | type: 2
894 | class: 1
895 | ttl: 5
896 | rdlength: 6
897 | rdata: 0x036e7335c04f
898 | rdata labels: 2
899 | rdata label: ns5 . msft . net .
900 | complete: yes
901 | ret: 0
902 | rr 8
903 | labels: 1
904 | label: ns1 . msft . net .
905 | question: no
906 | type: 1
907 | class: 1
908 | ttl: 5
909 | rdlength: 4
910 | rdata: 0x4137253e
911 | complete: yes
912 | ret: 0
913 | rr 9
914 | labels: 1
915 | label: ns1 . msft . net .
916 | question: no
917 | type: 28
918 | class: 1
919 | ttl: 5
920 | rdlength: 16
921 | rdata: 0x2a010111200500000000000000010001
922 | complete: yes
923 | ret: 0
924 | rr 10
925 | labels: 1
926 | label: ns2 . msft . net .
927 | question: no
928 | type: 1
929 | class: 1
930 | ttl: 5
931 | rdlength: 4
932 | rdata: 0x40043bad
933 | complete: yes
934 | ret: 0
935 | rr 11
936 | labels: 1
937 | label: ns2 . msft . net .
938 | question: no
939 | type: 28
940 | class: 1
941 | ttl: 5
942 | rdlength: 16
943 | rdata: 0x2a010111200600060000000000010001
944 | complete: yes
945 | ret: 0
946 | rr 12
947 | labels: 1
948 | label: ns3 . msft . net .
949 | question: no
950 | type: 1
951 | class: 1
952 | ttl: 5
953 | rdlength: 4
954 | rdata: 0xd5c7b435
955 | complete: yes
956 | ret: 0
957 | rr 13
958 | labels: 1
959 | label: ns3 . msft . net .
960 | question: no
961 | type: 28
962 | class: 1
963 | ttl: 5
964 | rdlength: 16
965 | rdata: 0x2a010111202000000000000000010001
966 | complete: yes
967 | ret: 0
968 | rr 14
969 | labels: 1
970 | label: ns4 . msft . net .
971 | question: no
972 | type: 1
973 | class: 1
974 | ttl: 5
975 | rdlength: 4
976 | rdata: 0xcf2e4bfe
977 | complete: yes
978 | ret: 0
979 | rr 15
980 | labels: 1
981 | label: ns4 . msft . net .
982 | question: no
983 | type: 28
984 | class: 1
985 | ttl: 5
986 | rdlength: 16
987 | rdata: 0x2404f800200300000000000000010001
988 | complete: yes
989 | ret: 0
990 | rr 16
991 | labels: 1
992 | label: ns5 . msft . net .
993 | question: no
994 | type: 1
995 | class: 1
996 | ttl: 5
997 | rdlength: 4
998 | rdata: 0x4137e28c
999 | complete: yes
1000 | ret: 0
1001 | rr 17
1002 | labels: 1
1003 | label: ns5 . msft . net .
1004 | question: no
1005 | type: 28
1006 | class: 1
1007 | ttl: 5
1008 | rdlength: 16
1009 | rdata: 0x2a010111200f00010000000000010001
1010 | complete: yes
1011 | ret: 0
1012 | rr 18
1013 | labels: 0
1014 | question: no
1015 | type: 41
1016 | class: 1280
1017 | ttl: 5
1018 | rdlength: 0
1019 | rdata: 0x
1020 | complete: yes
1021 | ret: 0
1022 | complete: yes
1023 | ret: 0
1024 | id: 29259
1025 | qr: 1
1026 | opcode: 0
1027 | aa: 0
1028 | tc: 0
1029 | rd: 1
1030 | ra: 1
1031 | z: 0
1032 | ad: 0
1033 | cd: 0
1034 | rcode: 0
1035 | qdcount: 1
1036 | ancount: 5
1037 | nscount: 4
1038 | arcount: 11
1039 | questions: 1
1040 | answers: 5
1041 | authorities: 4
1042 | additionals: 11
1043 | rr 0
1044 | labels: 2
1045 | label: google . com .
1046 | question: yes
1047 | type: 15
1048 | class: 1
1049 | complete: yes
1050 | ret: 0
1051 | rr 1
1052 | labels: 1
1053 | label: google . com .
1054 | question: no
1055 | type: 15
1056 | class: 1
1057 | ttl: 5
1058 | rdlength: 12
1059 | rdata: 0x000a056173706d78016cc00c
1060 | rdata labels: 3
1061 | rdata label: aspmx . l . google . com .
1062 | complete: yes
1063 | ret: 0
1064 | rr 2
1065 | labels: 1
1066 | label: google . com .
1067 | question: no
1068 | type: 15
1069 | class: 1
1070 | ttl: 5
1071 | rdlength: 9
1072 | rdata: 0x001404616c7431c02a
1073 | rdata labels: 2
1074 | rdata label: alt1 . aspmx . l . google . com .
1075 | complete: yes
1076 | ret: 0
1077 | rr 3
1078 | labels: 1
1079 | label: google . com .
1080 | question: no
1081 | type: 15
1082 | class: 1
1083 | ttl: 5
1084 | rdlength: 9
1085 | rdata: 0x001e04616c7432c02a
1086 | rdata labels: 2
1087 | rdata label: alt2 . aspmx . l . google . com .
1088 | complete: yes
1089 | ret: 0
1090 | rr 4
1091 | labels: 1
1092 | label: google . com .
1093 | question: no
1094 | type: 15
1095 | class: 1
1096 | ttl: 5
1097 | rdlength: 9
1098 | rdata: 0x002804616c7433c02a
1099 | rdata labels: 2
1100 | rdata label: alt3 . aspmx . l . google . com .
1101 | complete: yes
1102 | ret: 0
1103 | rr 5
1104 | labels: 1
1105 | label: google . com .
1106 | question: no
1107 | type: 15
1108 | class: 1
1109 | ttl: 5
1110 | rdlength: 9
1111 | rdata: 0x003204616c7434c02a
1112 | rdata labels: 2
1113 | rdata label: alt4 . aspmx . l . google . com .
1114 | complete: yes
1115 | ret: 0
1116 | rr 6
1117 | labels: 1
1118 | label: google . com .
1119 | question: no
1120 | type: 2
1121 | class: 1
1122 | ttl: 5
1123 | rdlength: 6
1124 | rdata: 0x036e7332c00c
1125 | rdata labels: 2
1126 | rdata label: ns2 . google . com .
1127 | complete: yes
1128 | ret: 0
1129 | rr 7
1130 | labels: 1
1131 | label: google . com .
1132 | question: no
1133 | type: 2
1134 | class: 1
1135 | ttl: 5
1136 | rdlength: 6
1137 | rdata: 0x036e7333c00c
1138 | rdata labels: 2
1139 | rdata label: ns3 . google . com .
1140 | complete: yes
1141 | ret: 0
1142 | rr 8
1143 | labels: 1
1144 | label: google . com .
1145 | question: no
1146 | type: 2
1147 | class: 1
1148 | ttl: 5
1149 | rdlength: 6
1150 | rdata: 0x036e7334c00c
1151 | rdata labels: 2
1152 | rdata label: ns4 . google . com .
1153 | complete: yes
1154 | ret: 0
1155 | rr 9
1156 | labels: 1
1157 | label: google . com .
1158 | question: no
1159 | type: 2
1160 | class: 1
1161 | ttl: 5
1162 | rdlength: 6
1163 | rdata: 0x036e7331c00c
1164 | rdata labels: 2
1165 | rdata label: ns1 . google . com .
1166 | complete: yes
1167 | ret: 0
1168 | rr 10
1169 | labels: 1
1170 | label: aspmx . l . google . com .
1171 | question: no
1172 | type: 1
1173 | class: 1
1174 | ttl: 5
1175 | rdlength: 4
1176 | rdata: 0xadc2421b
1177 | complete: yes
1178 | ret: 0
1179 | rr 11
1180 | labels: 1
1181 | label: aspmx . l . google . com .
1182 | question: no
1183 | type: 28
1184 | class: 1
1185 | ttl: 5
1186 | rdlength: 16
1187 | rdata: 0x2a00145040080c01000000000000001b
1188 | complete: yes
1189 | ret: 0
1190 | rr 12
1191 | labels: 1
1192 | label: alt1 . aspmx . l . google . com .
1193 | question: no
1194 | type: 1
1195 | class: 1
1196 | ttl: 5
1197 | rdlength: 4
1198 | rdata: 0xadc2461b
1199 | complete: yes
1200 | ret: 0
1201 | rr 13
1202 | labels: 1
1203 | label: alt2 . aspmx . l . google . com .
1204 | question: no
1205 | type: 1
1206 | class: 1
1207 | ttl: 5
1208 | rdlength: 4
1209 | rdata: 0xadc2451b
1210 | complete: yes
1211 | ret: 0
1212 | rr 14
1213 | labels: 1
1214 | label: alt3 . aspmx . l . google . com .
1215 | question: no
1216 | type: 1
1217 | class: 1
1218 | ttl: 5
1219 | rdlength: 4
1220 | rdata: 0x4a7d8f1b
1221 | complete: yes
1222 | ret: 0
1223 | rr 15
1224 | labels: 1
1225 | label: alt4 . aspmx . l . google . com .
1226 | question: no
1227 | type: 1
1228 | class: 1
1229 | ttl: 5
1230 | rdlength: 4
1231 | rdata: 0x4a7d191b
1232 | complete: yes
1233 | ret: 0
1234 | rr 16
1235 | labels: 1
1236 | label: ns1 . google . com .
1237 | question: no
1238 | type: 1
1239 | class: 1
1240 | ttl: 5
1241 | rdlength: 4
1242 | rdata: 0xd8ef200a
1243 | complete: yes
1244 | ret: 0
1245 | rr 17
1246 | labels: 1
1247 | label: ns2 . google . com .
1248 | question: no
1249 | type: 1
1250 | class: 1
1251 | ttl: 5
1252 | rdlength: 4
1253 | rdata: 0xd8ef220a
1254 | complete: yes
1255 | ret: 0
1256 | rr 18
1257 | labels: 1
1258 | label: ns3 . google . com .
1259 | question: no
1260 | type: 1
1261 | class: 1
1262 | ttl: 5
1263 | rdlength: 4
1264 | rdata: 0xd8ef240a
1265 | complete: yes
1266 | ret: 0
1267 | rr 19
1268 | labels: 1
1269 | label: ns4 . google . com .
1270 | question: no
1271 | type: 1
1272 | class: 1
1273 | ttl: 5
1274 | rdlength: 4
1275 | rdata: 0xd8ef260a
1276 | complete: yes
1277 | ret: 0
1278 | rr 20
1279 | labels: 0
1280 | question: no
1281 | type: 41
1282 | class: 1280
1283 | ttl: 5
1284 | rdlength: 0
1285 | rdata: 0x
1286 | complete: yes
1287 | ret: 0
1288 | complete: yes
1289 | ret: 0
1290 | id: 4793
1291 | qr: 1
1292 | opcode: 0
1293 | aa: 0
1294 | tc: 0
1295 | rd: 1
1296 | ra: 1
1297 | z: 0
1298 | ad: 0
1299 | cd: 0
1300 | rcode: 0
1301 | qdcount: 1
1302 | ancount: 8
1303 | nscount: 0
1304 | arcount: 12
1305 | questions: 1
1306 | answers: 8
1307 | authorities: 0
1308 | additionals: 12
1309 | rr 0
1310 | labels: 2
1311 | label: reddit . com .
1312 | question: yes
1313 | type: 2
1314 | class: 1
1315 | complete: yes
1316 | ret: 0
1317 | rr 1
1318 | labels: 1
1319 | label: reddit . com .
1320 | question: no
1321 | type: 2
1322 | class: 1
1323 | ttl: 5
1324 | rdlength: 15
1325 | rdata: 0x046175733204616b616d036e657400
1326 | rdata labels: 3
1327 | rdata label: aus2 . akam . net .
1328 | complete: yes
1329 | ret: 0
1330 | rr 2
1331 | labels: 1
1332 | label: reddit . com .
1333 | question: no
1334 | type: 2
1335 | class: 1
1336 | ttl: 5
1337 | rdlength: 7
1338 | rdata: 0x0475736534c02d
1339 | rdata labels: 2
1340 | rdata label: use4 . akam . net .
1341 | complete: yes
1342 | ret: 0
1343 | rr 3
1344 | labels: 1
1345 | label: reddit . com .
1346 | question: no
1347 | type: 2
1348 | class: 1
1349 | ttl: 5
1350 | rdlength: 7
1351 | rdata: 0x0475737733c02d
1352 | rdata labels: 2
1353 | rdata label: usw3 . akam . net .
1354 | complete: yes
1355 | ret: 0
1356 | rr 4
1357 | labels: 1
1358 | label: reddit . com .
1359 | question: no
1360 | type: 2
1361 | class: 1
1362 | ttl: 5
1363 | rdlength: 7
1364 | rdata: 0x0475737735c02d
1365 | rdata labels: 2
1366 | rdata label: usw5 . akam . net .
1367 | complete: yes
1368 | ret: 0
1369 | rr 5
1370 | labels: 1
1371 | label: reddit . com .
1372 | question: no
1373 | type: 2
1374 | class: 1
1375 | ttl: 5
1376 | rdlength: 8
1377 | rdata: 0x056173696131c02d
1378 | rdata labels: 2
1379 | rdata label: asia1 . akam . net .
1380 | complete: yes
1381 | ret: 0
1382 | rr 6
1383 | labels: 1
1384 | label: reddit . com .
1385 | question: no
1386 | type: 2
1387 | class: 1
1388 | ttl: 5
1389 | rdlength: 8
1390 | rdata: 0x056173696139c02d
1391 | rdata labels: 2
1392 | rdata label: asia9 . akam . net .
1393 | complete: yes
1394 | ret: 0
1395 | rr 7
1396 | labels: 1
1397 | label: reddit . com .
1398 | question: no
1399 | type: 2
1400 | class: 1
1401 | ttl: 5
1402 | rdlength: 8
1403 | rdata: 0x056e73312d31c02d
1404 | rdata labels: 2
1405 | rdata label: ns1-1 . akam . net .
1406 | complete: yes
1407 | ret: 0
1408 | rr 8
1409 | labels: 1
1410 | label: reddit . com .
1411 | question: no
1412 | type: 2
1413 | class: 1
1414 | ttl: 5
1415 | rdlength: 10
1416 | rdata: 0x076e73312d313935c02d
1417 | rdata labels: 2
1418 | rdata label: ns1-195 . akam . net .
1419 | complete: yes
1420 | ret: 0
1421 | rr 9
1422 | labels: 1
1423 | label: aus2 . akam . net .
1424 | question: no
1425 | type: 1
1426 | class: 1
1427 | ttl: 5
1428 | rdlength: 4
1429 | rdata: 0xc30a242e
1430 | complete: yes
1431 | ret: 0
1432 | rr 10
1433 | labels: 1
1434 | label: use4 . akam . net .
1435 | question: no
1436 | type: 1
1437 | class: 1
1438 | ttl: 5
1439 | rdlength: 4
1440 | rdata: 0x451f1d39
1441 | complete: yes
1442 | ret: 0
1443 | rr 11
1444 | labels: 1
1445 | label: usw3 . akam . net .
1446 | question: no
1447 | type: 1
1448 | class: 1
1449 | ttl: 5
1450 | rdlength: 4
1451 | rdata: 0x451f3bc7
1452 | complete: yes
1453 | ret: 0
1454 | rr 12
1455 | labels: 1
1456 | label: usw5 . akam . net .
1457 | question: no
1458 | type: 1
1459 | class: 1
1460 | ttl: 5
1461 | rdlength: 4
1462 | rdata: 0x60073240
1463 | complete: yes
1464 | ret: 0
1465 | rr 13
1466 | labels: 1
1467 | label: asia1 . akam . net .
1468 | question: no
1469 | type: 1
1470 | class: 1
1471 | ttl: 5
1472 | rdlength: 4
1473 | rdata: 0x6007fb81
1474 | complete: yes
1475 | ret: 0
1476 | rr 14
1477 | labels: 1
1478 | label: asia9 . akam . net .
1479 | question: no
1480 | type: 1
1481 | class: 1
1482 | ttl: 5
1483 | rdlength: 4
1484 | rdata: 0x7c283484
1485 | complete: yes
1486 | ret: 0
1487 | rr 15
1488 | labels: 1
1489 | label: asia9 . akam . net .
1490 | question: no
1491 | type: 28
1492 | class: 1
1493 | ttl: 5
1494 | rdlength: 16
1495 | rdata: 0x2a0226f0006700000000000000000064
1496 | complete: yes
1497 | ret: 0
1498 | rr 16
1499 | labels: 1
1500 | label: ns1-1 . akam . net .
1501 | question: no
1502 | type: 1
1503 | class: 1
1504 | ttl: 5
1505 | rdlength: 4
1506 | rdata: 0xc16c5b01
1507 | complete: yes
1508 | ret: 0
1509 | rr 17
1510 | labels: 1
1511 | label: ns1-1 . akam . net .
1512 | question: no
1513 | type: 28
1514 | class: 1
1515 | ttl: 5
1516 | rdlength: 16
1517 | rdata: 0x26001401000200000000000000000001
1518 | complete: yes
1519 | ret: 0
1520 | rr 18
1521 | labels: 1
1522 | label: ns1-195 . akam . net .
1523 | question: no
1524 | type: 1
1525 | class: 1
1526 | ttl: 5
1527 | rdlength: 4
1528 | rdata: 0xc16c5bc3
1529 | complete: yes
1530 | ret: 0
1531 | rr 19
1532 | labels: 1
1533 | label: ns1-195 . akam . net .
1534 | question: no
1535 | type: 28
1536 | class: 1
1537 | ttl: 5
1538 | rdlength: 16
1539 | rdata: 0x260014010002000000000000000000c3
1540 | complete: yes
1541 | ret: 0
1542 | rr 20
1543 | labels: 0
1544 | question: no
1545 | type: 41
1546 | class: 1280
1547 | ttl: 5
1548 | rdlength: 0
1549 | rdata: 0x
1550 | complete: yes
1551 | ret: 0
1552 | complete: yes
1553 | ret: 0
1554 |
--------------------------------------------------------------------------------
/hexdns2text/test/test2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -xe
2 | #
3 | # Author Jerry Lundström
4 | # Copyright (c) 2017, OARC, Inc.
5 | # All rights reserved.
6 | #
7 | # This file is part of omg-dns.
8 | #
9 | # omg-dns is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU Lesser General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # omg-dns is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU Lesser General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU Lesser General Public License
20 | # along with omg-dns. If not, see .
21 |
22 | ../hexdns2text \
23 | 064e81800001000b0004000506676f6f676c6503636f6d0000010001c00c00010001000000050004adc22986c00c00010001000000050004adc22987c00c00010001000000050004adc22988c00c00010001000000050004adc22989c00c00010001000000050004adc2298ec00c00010001000000050004adc22980c00c00010001000000050004adc22981c00c00010001000000050004adc22982c00c00010001000000050004adc22983c00c00010001000000050004adc22984c00c00010001000000050004adc22985c00c00020001000000050006036e7331c00cc00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc0d800010001000000050004d8ef200ac0ea00010001000000050004d8ef220ac0fc00010001000000050004d8ef240ac10e00010001000000050004d8ef260a0000290500000000050000 \
24 | 6de1818000010004000a000806616d617a6f6e03636f6d0000010001c00c000100010000000500044815c2d4c00c000100010000000500044815d7e8c00c00010001000000050004b02062a6c00c00010001000000050004cdfbf236c00c000200010000000500140570646e733408756c747261646e73036f726700c00c000200010000000500150570646e733508756c747261646e7304696e666f00c00c000200010000000500160570646e733608756c747261646e7302636f02756b00c00c00020001000000050014036e7331037033310664796e656374036e657400c00c00020001000000050006036e7332c0cfc00c00020001000000050006036e7333c0cfc00c00020001000000050006036e7334c0cfc00c000200010000000500110570646e733108756c747261646e73c0dac00c000200010000000500080570646e7332c127c00c000200010000000500080570646e7333c06ec0cb00010001000000050004d04e461fc0eb00010001000000050004cc0dfa1fc0fd00010001000000050004d04e471fc10f00010001000000050004cc0dfb1fc12100010001000000050004cc4a6c01c121001c000100000005001020010502f3ff00000000000000000001c13e00010001000000050004cc4a6d01c13e001c0001000000050010261000a1101400000000000000000001 \
25 | fc2d81800001000300070008057961686f6f03636f6d0000010001c00c00010001000000050004628afd6dc00c00010001000000050004628bb718c00c00010001000000050004cebe242dc00c00020001000000050006036e7336c00cc00c00020001000000050006036e7338c00cc00c00020001000000050006036e7331c00cc00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc00c00020001000000050006036e7335c00cc07b0001000100000005000444b48310c08d00010001000000050004448eff10c09f00010001000000050004cb54dd35c0b100010001000000050004628a0b9dc0c30001000100000005000477a0f77cc05700010001000000050004ca2bdfaac06900010001000000050004caa568160000290500000000050000 \
26 | f4368180000100020005000b096d6963726f736f667403636f6d0000010001c00c0001000100000005000440040b25c00c0001000100000005000441373ac9c00c0002000100000005000e036e7331046d736674036e657400c00c00020001000000050006036e7332c04fc00c00020001000000050006036e7333c04fc00c00020001000000050006036e7334c04fc00c00020001000000050006036e7335c04fc04b000100010000000500044137253ec04b001c00010000000500102a010111200500000000000000010001c0650001000100000005000440043badc065001c00010000000500102a010111200600060000000000010001c07700010001000000050004d5c7b435c077001c00010000000500102a010111202000000000000000010001c08900010001000000050004cf2e4bfec089001c00010000000500102404f800200300000000000000010001c09b000100010000000500044137e28cc09b001c00010000000500102a010111200f000100000000000100010000290500000000050000 \
27 | 724b8180000100050004000b06676f6f676c6503636f6d00000f0001c00c000f000100000005000c000a056173706d78016cc00cc00c000f0001000000050009001404616c7431c02ac00c000f0001000000050009001e04616c7432c02ac00c000f0001000000050009002804616c7433c02ac00c000f0001000000050009003204616c7434c02ac00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc00c00020001000000050006036e7331c00cc02a00010001000000050004adc2421bc02a001c00010000000500102a00145040080c01000000000000001bc04200010001000000050004adc2461bc05700010001000000050004adc2451bc06c000100010000000500044a7d8f1bc081000100010000000500044a7d191bc0ca00010001000000050004d8ef200ac09400010001000000050004d8ef220ac0a600010001000000050004d8ef240ac0b800010001000000050004d8ef260a0000290500000000050000 \
28 | 12b98180000100080000000c0672656464697403636f6d0000020001c00c0002000100000005000f046175733204616b616d036e657400c00c000200010000000500070475736534c02dc00c000200010000000500070475737733c02dc00c000200010000000500070475737735c02dc00c00020001000000050008056173696131c02dc00c00020001000000050008056173696139c02dc00c00020001000000050008056e73312d31c02dc00c0002000100000005000a076e73312d313935c02dc02800010001000000050004c30a242ec04300010001000000050004451f1d39c05600010001000000050004451f3bc7c0690001000100000005000460073240c07c000100010000000500046007fb81c090000100010000000500047c283484c090001c00010000000500102a0226f0006700000000000000000064c0a400010001000000050004c16c5b01c0a4001c000100000005001026001401000200000000000000000001c0b800010001000000050004c16c5bc3c0b8001c0001000000050010260014010002000000000000000000c30000290500000000050000 \
29 | > test2.out
30 |
31 | diff test2.out "$srcdir/test2.gold"
32 |
--------------------------------------------------------------------------------
/omg_dns.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Author Jerry Lundström
3 | * Copyright (c) 2017, OARC, Inc.
4 | * All rights reserved.
5 | *
6 | * This file is part of omg-dns.
7 | *
8 | * omg-dns is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * omg-dns is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with omg-dns. If not, see .
20 | */
21 |
22 | #if HAVE_CONFIG_H
23 | #include "config.h"
24 | #endif
25 | #include "omg_dns.h"
26 |
27 | /*
28 | * Version
29 | */
30 |
31 | static const char* _version = OMG_DNS_VERSION_STR;
32 | inline const char* omg_dns_version_str(void)
33 | {
34 | return _version;
35 | }
36 |
37 | inline int omg_dns_version_major(void)
38 | {
39 | return OMG_DNS_VERSION_MAJOR;
40 | }
41 |
42 | inline int omg_dns_version_minor(void)
43 | {
44 | return OMG_DNS_VERSION_MINOR;
45 | }
46 |
47 | inline int omg_dns_version_patch(void)
48 | {
49 | return OMG_DNS_VERSION_PATCH;
50 | }
51 |
52 | /*
53 | * Buffer inlines and macros
54 | */
55 |
56 | #define need8(v, p, l) \
57 | if (l < 1) { \
58 | return OMG_DNS_EINCOMP; \
59 | } \
60 | v = *p; \
61 | p += 1; \
62 | l -= 1
63 |
64 | #define need16(v, p, l) \
65 | if (l < 2) { \
66 | return OMG_DNS_EINCOMP; \
67 | } \
68 | v = (*p << 8) + *(p + 1); \
69 | p += 2; \
70 | l -= 2
71 |
72 | #define need32(v, p, l) \
73 | if (l < 4) { \
74 | return OMG_DNS_EINCOMP; \
75 | } \
76 | v = (*p << 24) + (*(p + 1) << 16) + (*(p + 2) << 8) + *(p + 3); \
77 | p += 4; \
78 | l -= 4
79 |
80 | #define need64(v, p, l) \
81 | if (l < 8) { \
82 | return OMG_DNS_EINCOMP; \
83 | } \
84 | v = (*p << 56) + (*(p + 1) << 48) + (*(p + 2) << 40) + (*(p + 3) << 32) + (*(p + 4) << 24) + (*(p + 5) << 16) + (*(p + 6) << 8) + *(p + 7); \
85 | p += 8; \
86 | l -= 8
87 |
88 | #define needxb(b, x, p, l) \
89 | if (l < x) { \
90 | return OMG_DNS_EINCOMP; \
91 | } \
92 | memcpy(b, p, x); \
93 | p += x; \
94 | l -= x
95 |
96 | #define advancexb(x, p, l) \
97 | if (l < x) { \
98 | return OMG_DNS_EINCOMP; \
99 | } \
100 | p += x; \
101 | l -= x
102 |
103 | /*
104 | * Label structure functions
105 | */
106 |
107 | inline int omg_dns_label_is_end(const omg_dns_label_t* label)
108 | {
109 | omg_dns_assert(label);
110 | return label->is_end;
111 | }
112 |
113 | inline int omg_dns_label_have_length(const omg_dns_label_t* label)
114 | {
115 | omg_dns_assert(label);
116 | return label->have_length;
117 | }
118 |
119 | inline int omg_dns_label_have_offset(const omg_dns_label_t* label)
120 | {
121 | omg_dns_assert(label);
122 | return label->have_offset;
123 | }
124 |
125 | inline int omg_dns_label_have_extension_bits(const omg_dns_label_t* label)
126 | {
127 | omg_dns_assert(label);
128 | return label->have_extension_bits;
129 | }
130 |
131 | inline int omg_dns_label_have_dn(const omg_dns_label_t* label)
132 | {
133 | omg_dns_assert(label);
134 | return label->have_dn;
135 | }
136 |
137 | inline int omg_dns_label_is_complete(const omg_dns_label_t* label)
138 | {
139 | omg_dns_assert(label);
140 | return label->is_complete;
141 | }
142 |
143 | inline uint8_t omg_dns_label_length(const omg_dns_label_t* label)
144 | {
145 | omg_dns_assert(label);
146 | return label->length;
147 | }
148 |
149 | inline uint16_t omg_dns_label_offset(const omg_dns_label_t* label)
150 | {
151 | omg_dns_assert(label);
152 | return label->offset;
153 | }
154 |
155 | inline unsigned short omg_dns_label_extension_bits(const omg_dns_label_t* label)
156 | {
157 | omg_dns_assert(label);
158 | return label->extension_bits;
159 | }
160 |
161 | inline size_t omg_dns_label_dn_offset(const omg_dns_label_t* label)
162 | {
163 | omg_dns_assert(label);
164 | return label->dn_offset;
165 | }
166 |
167 | /*
168 | * Resource record structure callback functions
169 | */
170 |
171 | inline omg_dns_label_callback_t omg_dns_rr_label_callback(const omg_dns_rr_t* rr)
172 | {
173 | omg_dns_assert(rr);
174 | return rr->label_callback;
175 | }
176 |
177 | inline void* omg_dns_rr_label_callback_context(const omg_dns_rr_t* rr)
178 | {
179 | omg_dns_assert(rr);
180 | return rr->label_callback_context;
181 | }
182 |
183 | inline void omg_dns_rr_set_label_callback(omg_dns_rr_t* rr, omg_dns_label_callback_t label_callback, void* label_callback_context)
184 | {
185 | omg_dns_assert(rr);
186 | rr->label_callback = label_callback;
187 | rr->label_callback_context = label_callback_context;
188 | }
189 |
190 | /*
191 | * Resource record structure functions
192 | */
193 |
194 | inline int omg_dns_rr_is_question(const omg_dns_rr_t* rr)
195 | {
196 | omg_dns_assert(rr);
197 | return rr->is_question;
198 | }
199 |
200 | inline int omg_dns_rr_have_labels(const omg_dns_rr_t* rr)
201 | {
202 | omg_dns_assert(rr);
203 | return rr->have_labels;
204 | }
205 |
206 | inline int omg_dns_rr_have_type(const omg_dns_rr_t* rr)
207 | {
208 | omg_dns_assert(rr);
209 | return rr->have_type;
210 | }
211 |
212 | inline int omg_dns_rr_have_class(const omg_dns_rr_t* rr)
213 | {
214 | omg_dns_assert(rr);
215 | return rr->have_class;
216 | }
217 |
218 | inline int omg_dns_rr_have_ttl(const omg_dns_rr_t* rr)
219 | {
220 | omg_dns_assert(rr);
221 | return rr->have_ttl;
222 | }
223 |
224 | inline int omg_dns_rr_have_rdlength(const omg_dns_rr_t* rr)
225 | {
226 | omg_dns_assert(rr);
227 | return rr->have_rdlength;
228 | }
229 |
230 | inline int omg_dns_rr_have_rdata(const omg_dns_rr_t* rr)
231 | {
232 | omg_dns_assert(rr);
233 | return rr->have_rdata;
234 | }
235 |
236 | inline int omg_dns_rr_have_rdata_labels(const omg_dns_rr_t* rr)
237 | {
238 | omg_dns_assert(rr);
239 | return rr->have_rdata_labels;
240 | }
241 |
242 | inline int omg_dns_rr_have_padding(const omg_dns_rr_t* rr)
243 | {
244 | omg_dns_assert(rr);
245 | return rr->have_padding;
246 | }
247 |
248 | inline int omg_dns_rr_is_complete(const omg_dns_rr_t* rr)
249 | {
250 | omg_dns_assert(rr);
251 | return rr->is_complete;
252 | }
253 |
254 | inline size_t omg_dns_rr_bytes_parsed(const omg_dns_rr_t* rr)
255 | {
256 | omg_dns_assert(rr);
257 | return rr->bytes_parsed;
258 | }
259 |
260 | inline size_t omg_dns_rr_labels(const omg_dns_rr_t* rr)
261 | {
262 | omg_dns_assert(rr);
263 | return rr->labels;
264 | }
265 |
266 | inline uint16_t omg_dns_rr_type(const omg_dns_rr_t* rr)
267 | {
268 | omg_dns_assert(rr);
269 | return rr->type;
270 | }
271 |
272 | inline uint16_t omg_dns_rr_class(const omg_dns_rr_t* rr)
273 | {
274 | omg_dns_assert(rr);
275 | return rr->class;
276 | }
277 |
278 | inline uint32_t omg_dns_rr_ttl(const omg_dns_rr_t* rr)
279 | {
280 | omg_dns_assert(rr);
281 | return rr->ttl;
282 | }
283 |
284 | inline uint16_t omg_dns_rr_rdlength(const omg_dns_rr_t* rr)
285 | {
286 | omg_dns_assert(rr);
287 | return rr->rdlength;
288 | }
289 |
290 | inline size_t omg_dns_rr_rdata_offset(const omg_dns_rr_t* rr)
291 | {
292 | omg_dns_assert(rr);
293 | return rr->rdata_offset;
294 | }
295 |
296 | inline size_t omg_dns_rr_rdata_labels(const omg_dns_rr_t* rr)
297 | {
298 | omg_dns_assert(rr);
299 | return rr->rdata_labels;
300 | }
301 |
302 | inline size_t omg_dns_rr_padding_offset(const omg_dns_rr_t* rr)
303 | {
304 | omg_dns_assert(rr);
305 | return rr->padding_offset;
306 | }
307 |
308 | inline size_t omg_dns_rr_padding_length(const omg_dns_rr_t* rr)
309 | {
310 | omg_dns_assert(rr);
311 | return rr->padding_length;
312 | }
313 |
314 | inline size_t omg_dns_rr_num_rdata_labels(const omg_dns_rr_t* rr)
315 | {
316 | omg_dns_assert(rr);
317 |
318 | switch (rr->type) {
319 | case OMG_DNS_TYPE_NS:
320 | case OMG_DNS_TYPE_MD:
321 | case OMG_DNS_TYPE_MF:
322 | case OMG_DNS_TYPE_CNAME:
323 | case OMG_DNS_TYPE_MB:
324 | case OMG_DNS_TYPE_MG:
325 | case OMG_DNS_TYPE_MR:
326 | case OMG_DNS_TYPE_PTR:
327 | case OMG_DNS_TYPE_NXT:
328 | case OMG_DNS_TYPE_DNAME:
329 | case OMG_DNS_TYPE_NSEC:
330 | case OMG_DNS_TYPE_TKEY:
331 | case OMG_DNS_TYPE_TSIG:
332 | return 1;
333 |
334 | case OMG_DNS_TYPE_SOA:
335 | case OMG_DNS_TYPE_MINFO:
336 | case OMG_DNS_TYPE_RP:
337 | case OMG_DNS_TYPE_TALINK:
338 | return 2;
339 |
340 | case OMG_DNS_TYPE_MX:
341 | case OMG_DNS_TYPE_AFSDB:
342 | case OMG_DNS_TYPE_RT:
343 | case OMG_DNS_TYPE_KX:
344 | case OMG_DNS_TYPE_LP:
345 | return 1;
346 |
347 | case OMG_DNS_TYPE_PX:
348 | return 2;
349 |
350 | case OMG_DNS_TYPE_SIG:
351 | case OMG_DNS_TYPE_RRSIG:
352 | return 1;
353 |
354 | case OMG_DNS_TYPE_SRV:
355 | return 1;
356 |
357 | case OMG_DNS_TYPE_NAPTR:
358 | return 1;
359 |
360 | case OMG_DNS_TYPE_HIP:
361 | return 1;
362 |
363 | default:
364 | break;
365 | }
366 |
367 | return 0;
368 | }
369 |
370 | /*
371 | * DNS structure callback functions
372 | */
373 |
374 | inline omg_dns_label_callback_t omg_dns_label_callback(const omg_dns_t* dns)
375 | {
376 | omg_dns_assert(dns);
377 | return dns->label_callback;
378 | }
379 |
380 | inline void* omg_dns_label_callback_context(const omg_dns_t* dns)
381 | {
382 | omg_dns_assert(dns);
383 | return dns->label_callback_context;
384 | }
385 |
386 | inline void omg_dns_set_label_callback(omg_dns_t* dns, omg_dns_label_callback_t label_callback, void* label_callback_context)
387 | {
388 | omg_dns_assert(dns);
389 | dns->label_callback = label_callback;
390 | dns->label_callback_context = label_callback_context;
391 | }
392 |
393 | inline omg_dns_rr_callback_t omg_dns_rr_callback(const omg_dns_t* dns)
394 | {
395 | omg_dns_assert(dns);
396 | return dns->rr_callback;
397 | }
398 |
399 | inline void* omg_dns_rr_callback_context(const omg_dns_t* dns)
400 | {
401 | omg_dns_assert(dns);
402 | return dns->rr_callback_context;
403 | }
404 |
405 | inline void omg_dns_set_rr_callback(omg_dns_t* dns, omg_dns_rr_callback_t rr_callback, void* rr_callback_context)
406 | {
407 | omg_dns_assert(dns);
408 | dns->rr_callback = rr_callback;
409 | dns->rr_callback_context = rr_callback_context;
410 | }
411 |
412 | /*
413 | * DNS structure functions
414 | */
415 |
416 | inline int omg_dns_have_id(const omg_dns_t* dns)
417 | {
418 | omg_dns_assert(dns);
419 | return dns->have_id;
420 | }
421 |
422 | inline int omg_dns_have_qr(const omg_dns_t* dns)
423 | {
424 | omg_dns_assert(dns);
425 | return dns->have_qr;
426 | }
427 |
428 | inline int omg_dns_have_opcode(const omg_dns_t* dns)
429 | {
430 | omg_dns_assert(dns);
431 | return dns->have_opcode;
432 | }
433 |
434 | inline int omg_dns_have_aa(const omg_dns_t* dns)
435 | {
436 | omg_dns_assert(dns);
437 | return dns->have_aa;
438 | }
439 |
440 | inline int omg_dns_have_tc(const omg_dns_t* dns)
441 | {
442 | omg_dns_assert(dns);
443 | return dns->have_tc;
444 | }
445 |
446 | inline int omg_dns_have_rd(const omg_dns_t* dns)
447 | {
448 | omg_dns_assert(dns);
449 | return dns->have_rd;
450 | }
451 |
452 | inline int omg_dns_have_ra(const omg_dns_t* dns)
453 | {
454 | omg_dns_assert(dns);
455 | return dns->have_ra;
456 | }
457 |
458 | inline int omg_dns_have_z(const omg_dns_t* dns)
459 | {
460 | omg_dns_assert(dns);
461 | return dns->have_z;
462 | }
463 |
464 | inline int omg_dns_have_ad(const omg_dns_t* dns)
465 | {
466 | omg_dns_assert(dns);
467 | return dns->have_ad;
468 | }
469 |
470 | inline int omg_dns_have_cd(const omg_dns_t* dns)
471 | {
472 | omg_dns_assert(dns);
473 | return dns->have_cd;
474 | }
475 |
476 | inline int omg_dns_have_rcode(const omg_dns_t* dns)
477 | {
478 | omg_dns_assert(dns);
479 | return dns->have_rcode;
480 | }
481 |
482 | inline int omg_dns_have_qdcount(const omg_dns_t* dns)
483 | {
484 | omg_dns_assert(dns);
485 | return dns->have_qdcount;
486 | }
487 |
488 | inline int omg_dns_have_ancount(const omg_dns_t* dns)
489 | {
490 | omg_dns_assert(dns);
491 | return dns->have_ancount;
492 | }
493 |
494 | inline int omg_dns_have_nscount(const omg_dns_t* dns)
495 | {
496 | omg_dns_assert(dns);
497 | return dns->have_nscount;
498 | }
499 |
500 | inline int omg_dns_have_arcount(const omg_dns_t* dns)
501 | {
502 | omg_dns_assert(dns);
503 | return dns->have_arcount;
504 | }
505 |
506 | inline int omg_dns_have_questions(const omg_dns_t* dns)
507 | {
508 | omg_dns_assert(dns);
509 | return dns->have_questions;
510 | }
511 |
512 | inline int omg_dns_have_answers(const omg_dns_t* dns)
513 | {
514 | omg_dns_assert(dns);
515 | return dns->have_answers;
516 | }
517 |
518 | inline int omg_dns_have_authorities(const omg_dns_t* dns)
519 | {
520 | omg_dns_assert(dns);
521 | return dns->have_authorities;
522 | }
523 |
524 | inline int omg_dns_have_additionals(const omg_dns_t* dns)
525 | {
526 | omg_dns_assert(dns);
527 | return dns->have_additionals;
528 | }
529 |
530 | inline int omg_dns_have_padding(const omg_dns_t* dns)
531 | {
532 | omg_dns_assert(dns);
533 | return dns->have_padding;
534 | }
535 |
536 | inline int omg_dns_have_header(const omg_dns_t* dns)
537 | {
538 | omg_dns_assert(dns);
539 | return dns->have_header;
540 | }
541 |
542 | inline int omg_dns_have_body(const omg_dns_t* dns)
543 | {
544 | omg_dns_assert(dns);
545 | return dns->have_body;
546 | }
547 |
548 | inline int omg_dns_is_complete(const omg_dns_t* dns)
549 | {
550 | omg_dns_assert(dns);
551 | return dns->is_complete;
552 | }
553 |
554 | inline size_t omg_dns_bytes_parsed(const omg_dns_t* dns)
555 | {
556 | omg_dns_assert(dns);
557 | return dns->bytes_parsed;
558 | }
559 |
560 | inline uint16_t omg_dns_id(const omg_dns_t* dns)
561 | {
562 | omg_dns_assert(dns);
563 | return dns->id;
564 | }
565 |
566 | inline int omg_dns_qr(const omg_dns_t* dns)
567 | {
568 | omg_dns_assert(dns);
569 | return dns->qr;
570 | }
571 |
572 | inline int omg_dns_opcode(const omg_dns_t* dns)
573 | {
574 | omg_dns_assert(dns);
575 | return dns->opcode;
576 | }
577 |
578 | inline int omg_dns_aa(const omg_dns_t* dns)
579 | {
580 | omg_dns_assert(dns);
581 | return dns->aa;
582 | }
583 |
584 | inline int omg_dns_tc(const omg_dns_t* dns)
585 | {
586 | omg_dns_assert(dns);
587 | return dns->tc;
588 | }
589 |
590 | inline int omg_dns_rd(const omg_dns_t* dns)
591 | {
592 | omg_dns_assert(dns);
593 | return dns->rd;
594 | }
595 |
596 | inline int omg_dns_ra(const omg_dns_t* dns)
597 | {
598 | omg_dns_assert(dns);
599 | return dns->ra;
600 | }
601 |
602 | inline int omg_dns_z(const omg_dns_t* dns)
603 | {
604 | omg_dns_assert(dns);
605 | return dns->z;
606 | }
607 |
608 | inline int omg_dns_ad(const omg_dns_t* dns)
609 | {
610 | omg_dns_assert(dns);
611 | return dns->ad;
612 | }
613 |
614 | inline int omg_dns_cd(const omg_dns_t* dns)
615 | {
616 | omg_dns_assert(dns);
617 | return dns->cd;
618 | }
619 |
620 | inline int omg_dns_rcode(const omg_dns_t* dns)
621 | {
622 | omg_dns_assert(dns);
623 | return dns->rcode;
624 | }
625 |
626 | inline uint16_t omg_dns_qdcount(const omg_dns_t* dns)
627 | {
628 | omg_dns_assert(dns);
629 | return dns->qdcount;
630 | }
631 |
632 | inline uint16_t omg_dns_ancount(const omg_dns_t* dns)
633 | {
634 | omg_dns_assert(dns);
635 | return dns->ancount;
636 | }
637 |
638 | inline uint16_t omg_dns_nscount(const omg_dns_t* dns)
639 | {
640 | omg_dns_assert(dns);
641 | return dns->nscount;
642 | }
643 |
644 | inline uint16_t omg_dns_arcount(const omg_dns_t* dns)
645 | {
646 | omg_dns_assert(dns);
647 | return dns->arcount;
648 | }
649 |
650 | inline size_t omg_dns_questions(const omg_dns_t* dns)
651 | {
652 | omg_dns_assert(dns);
653 | return dns->questions;
654 | }
655 |
656 | inline size_t omg_dns_answers(const omg_dns_t* dns)
657 | {
658 | omg_dns_assert(dns);
659 | return dns->answers;
660 | }
661 |
662 | inline size_t omg_dns_authorities(const omg_dns_t* dns)
663 | {
664 | omg_dns_assert(dns);
665 | return dns->authorities;
666 | }
667 |
668 | inline size_t omg_dns_additionals(const omg_dns_t* dns)
669 | {
670 | omg_dns_assert(dns);
671 | return dns->additionals;
672 | }
673 |
674 | inline size_t omg_dns_padding_offset(const omg_dns_t* dns)
675 | {
676 | omg_dns_assert(dns);
677 | return dns->padding_offset;
678 | }
679 |
680 | inline size_t omg_dns_padding_length(const omg_dns_t* dns)
681 | {
682 | omg_dns_assert(dns);
683 | return dns->padding_length;
684 | }
685 |
686 | /*
687 | * Parsers
688 | */
689 |
690 | int omg_dns_parse_header(omg_dns_t* dns, const uint8_t* buffer, size_t length)
691 | {
692 | uint8_t byte;
693 |
694 | if (!dns) {
695 | return OMG_DNS_EINVAL;
696 | }
697 |
698 | need16(dns->id, buffer, length);
699 | dns->bytes_parsed += 2;
700 | dns->have_id = 1;
701 |
702 | need8(byte, buffer, length);
703 | dns->bytes_parsed += 1;
704 | dns->qr = byte & (1 << 7) ? 1 : 0;
705 | dns->opcode = (byte >> 3) & 0xf;
706 | dns->aa = byte & (1 << 2) ? 1 : 0;
707 | dns->tc = byte & (1 << 1) ? 1 : 0;
708 | dns->rd = byte & (1 << 0) ? 1 : 0;
709 | dns->have_qr = dns->have_opcode = dns->have_aa = dns->have_tc = dns->have_rd = 1;
710 |
711 | need8(byte, buffer, length);
712 | dns->bytes_parsed += 1;
713 | dns->ra = byte & (1 << 7) ? 1 : 0;
714 | dns->z = byte & (1 << 6) ? 1 : 0;
715 | dns->ad = byte & (1 << 5) ? 1 : 0;
716 | dns->cd = byte & (1 << 4) ? 1 : 0;
717 | dns->rcode = byte & 0xf;
718 | dns->have_ra = dns->have_z = dns->have_ad = dns->have_cd = dns->have_rcode = 1;
719 |
720 | need16(dns->qdcount, buffer, length);
721 | dns->bytes_parsed += 2;
722 | dns->have_qdcount = 1;
723 |
724 | need16(dns->ancount, buffer, length);
725 | dns->bytes_parsed += 2;
726 | dns->have_ancount = 1;
727 |
728 | need16(dns->nscount, buffer, length);
729 | dns->bytes_parsed += 2;
730 | dns->have_nscount = 1;
731 |
732 | need16(dns->arcount, buffer, length);
733 | dns->bytes_parsed += 2;
734 | dns->have_arcount = 1;
735 |
736 | dns->have_header = 1;
737 |
738 | return OMG_DNS_OK;
739 | }
740 |
741 | int omg_dns_parse_body(omg_dns_t* dns, const uint8_t* buffer, size_t length)
742 | {
743 | size_t n;
744 | int ret;
745 |
746 | if (!dns) {
747 | return OMG_DNS_EINVAL;
748 | }
749 |
750 | for (n = dns->qdcount; n; n--) {
751 | omg_dns_rr_t rr = OMG_DNS_RR_T_INIT;
752 |
753 | rr._offset = dns->bytes_parsed;
754 | rr.is_question = 1;
755 | if (dns->label_callback)
756 | omg_dns_rr_set_label_callback(&rr, dns->label_callback, dns->label_callback_context);
757 | ret = omg_dns_parse_rr(&rr, buffer, length);
758 | if (dns->rr_callback)
759 | ret = dns->rr_callback(ret, &rr, dns->rr_callback_context);
760 | if (ret != OMG_DNS_OK)
761 | return ret;
762 |
763 | buffer += rr.bytes_parsed;
764 | length -= rr.bytes_parsed;
765 | dns->bytes_parsed += rr.bytes_parsed;
766 |
767 | dns->questions++;
768 | }
769 | dns->have_questions = 1;
770 |
771 | for (n = dns->ancount; n; n--) {
772 | omg_dns_rr_t rr = OMG_DNS_RR_T_INIT;
773 |
774 | rr._offset = dns->bytes_parsed;
775 | if (dns->label_callback)
776 | omg_dns_rr_set_label_callback(&rr, dns->label_callback, dns->label_callback_context);
777 | ret = omg_dns_parse_rr(&rr, buffer, length);
778 | if (dns->rr_callback)
779 | ret = dns->rr_callback(ret, &rr, dns->rr_callback_context);
780 | if (ret != OMG_DNS_OK)
781 | return ret;
782 |
783 | buffer += rr.bytes_parsed;
784 | length -= rr.bytes_parsed;
785 | dns->bytes_parsed += rr.bytes_parsed;
786 |
787 | dns->answers++;
788 | }
789 | dns->have_answers = 1;
790 |
791 | for (n = dns->nscount; n; n--) {
792 | omg_dns_rr_t rr = OMG_DNS_RR_T_INIT;
793 |
794 | rr._offset = dns->bytes_parsed;
795 | if (dns->label_callback)
796 | omg_dns_rr_set_label_callback(&rr, dns->label_callback, dns->label_callback_context);
797 | ret = omg_dns_parse_rr(&rr, buffer, length);
798 | if (dns->rr_callback)
799 | ret = dns->rr_callback(ret, &rr, dns->rr_callback_context);
800 | if (ret != OMG_DNS_OK)
801 | return ret;
802 |
803 | buffer += rr.bytes_parsed;
804 | length -= rr.bytes_parsed;
805 | dns->bytes_parsed += rr.bytes_parsed;
806 |
807 | dns->authorities++;
808 | }
809 | dns->have_authorities = 1;
810 |
811 | for (n = dns->arcount; n; n--) {
812 | omg_dns_rr_t rr = OMG_DNS_RR_T_INIT;
813 |
814 | rr._offset = dns->bytes_parsed;
815 | if (dns->label_callback)
816 | omg_dns_rr_set_label_callback(&rr, dns->label_callback, dns->label_callback_context);
817 | ret = omg_dns_parse_rr(&rr, buffer, length);
818 | if (dns->rr_callback)
819 | ret = dns->rr_callback(ret, &rr, dns->rr_callback_context);
820 | if (ret != OMG_DNS_OK)
821 | return ret;
822 |
823 | buffer += rr.bytes_parsed;
824 | length -= rr.bytes_parsed;
825 | dns->bytes_parsed += rr.bytes_parsed;
826 |
827 | dns->additionals++;
828 | }
829 | dns->have_additionals = 1;
830 |
831 | if (length) {
832 | dns->padding_offset = dns->bytes_parsed;
833 | dns->padding_length = length;
834 | dns->have_padding = 1;
835 | }
836 |
837 | dns->have_body = 1;
838 |
839 | return OMG_DNS_OK;
840 | }
841 |
842 | int omg_dns_parse(omg_dns_t* dns, const uint8_t* buffer, size_t length)
843 | {
844 | int ret;
845 |
846 | if (!dns) {
847 | return OMG_DNS_EINVAL;
848 | }
849 |
850 | if ((ret = omg_dns_parse_header(dns, buffer, length)) != OMG_DNS_OK) {
851 | return ret;
852 | }
853 | if (length <= dns->bytes_parsed) {
854 | return OMG_DNS_EINCOMP;
855 | }
856 | buffer += dns->bytes_parsed;
857 | length -= dns->bytes_parsed;
858 |
859 | if ((ret = omg_dns_parse_body(dns, buffer, length)) != OMG_DNS_OK) {
860 | return ret;
861 | }
862 |
863 | dns->is_complete = 1;
864 |
865 | return OMG_DNS_OK;
866 | }
867 |
868 | int omg_dns_parse_rr(omg_dns_rr_t* rr, const uint8_t* buffer, size_t length)
869 | {
870 | int ret;
871 | size_t labels;
872 |
873 | if (!rr) {
874 | return OMG_DNS_EINVAL;
875 | }
876 |
877 | while (length) {
878 | omg_dns_label_t label = OMG_DNS_LABEL_T_INIT;
879 |
880 | label._offset = rr->_offset + rr->bytes_parsed;
881 | need8(label.length, buffer, length);
882 | rr->bytes_parsed += 1;
883 |
884 | if ((label.length & 0xc0) == 0xc0) {
885 | need8(label.offset, buffer, length);
886 | label.offset |= (label.length & 0x3f) << 8;
887 | rr->bytes_parsed += 1;
888 | label.have_offset = 1;
889 |
890 | label.is_complete = 1;
891 | if (rr->label_callback) {
892 | ret = rr->label_callback(&label, rr->label_callback_context);
893 | if (ret != OMG_DNS_OK)
894 | return ret;
895 | }
896 | rr->labels++;
897 | break;
898 | } else if (label.length & 0xc0) {
899 | label.extension_bits = label.length >> 6;
900 | label.have_extension_bits = 1;
901 |
902 | label.is_complete = 1;
903 | if (rr->label_callback) {
904 | ret = rr->label_callback(&label, rr->label_callback_context);
905 | if (ret != OMG_DNS_OK)
906 | return ret;
907 | }
908 | rr->labels++;
909 | break;
910 | } else if (label.length) {
911 | label.have_length = 1;
912 |
913 | label.offset = label._offset;
914 | label.dn_offset = label._offset + 1;
915 | advancexb(label.length, buffer, length);
916 | rr->bytes_parsed += label.length;
917 | label.have_dn = 1;
918 |
919 | label.is_complete = 1;
920 | if (rr->label_callback) {
921 | ret = rr->label_callback(&label, rr->label_callback_context);
922 | if (ret != OMG_DNS_OK)
923 | return ret;
924 | }
925 | rr->labels++;
926 | } else {
927 | label.is_end = 1;
928 | label.is_complete = 1;
929 | if (rr->label_callback) {
930 | ret = rr->label_callback(&label, rr->label_callback_context);
931 | if (ret != OMG_DNS_OK)
932 | return ret;
933 | }
934 | break;
935 | }
936 | }
937 | rr->have_labels = 1;
938 |
939 | need16(rr->type, buffer, length);
940 | rr->bytes_parsed += 2;
941 | rr->have_type = 1;
942 |
943 | need16(rr->class, buffer, length);
944 | rr->bytes_parsed += 2;
945 | rr->have_class = 1;
946 |
947 | if (rr->is_question) {
948 | rr->is_complete = 1;
949 | return OMG_DNS_OK;
950 | }
951 |
952 | need32(rr->ttl, buffer, length);
953 | rr->bytes_parsed += 4;
954 | rr->have_ttl = 1;
955 |
956 | need16(rr->rdlength, buffer, length);
957 | rr->bytes_parsed += 2;
958 | rr->have_rdlength = 1;
959 |
960 | rr->rdata_offset = rr->_offset + rr->bytes_parsed;
961 |
962 | if ((labels = omg_dns_rr_num_rdata_labels(rr))) {
963 | size_t bytes_parsed = 0;
964 |
965 | switch (rr->type) {
966 | case OMG_DNS_TYPE_MX:
967 | case OMG_DNS_TYPE_AFSDB:
968 | case OMG_DNS_TYPE_RT:
969 | case OMG_DNS_TYPE_KX:
970 | case OMG_DNS_TYPE_LP:
971 | case OMG_DNS_TYPE_PX:
972 | advancexb(2, buffer, length);
973 | rr->bytes_parsed += 2;
974 | bytes_parsed += 2;
975 | break;
976 |
977 | case OMG_DNS_TYPE_SIG:
978 | case OMG_DNS_TYPE_RRSIG:
979 | advancexb(18, buffer, length);
980 | rr->bytes_parsed += 18;
981 | bytes_parsed += 18;
982 | break;
983 |
984 | case OMG_DNS_TYPE_SRV:
985 | advancexb(6, buffer, length);
986 | rr->bytes_parsed += 6;
987 | bytes_parsed += 6;
988 | break;
989 |
990 | case OMG_DNS_TYPE_NAPTR: {
991 | uint8_t naptr_length;
992 |
993 | /* 2x 16 bits */
994 | advancexb(4, buffer, length);
995 | rr->bytes_parsed += 4;
996 | bytes_parsed += 4;
997 |
998 | need8(naptr_length, buffer, length);
999 | rr->bytes_parsed += 1;
1000 | bytes_parsed += 1;
1001 | advancexb(naptr_length, buffer, length);
1002 | rr->bytes_parsed += naptr_length;
1003 | bytes_parsed += naptr_length;
1004 |
1005 | need8(naptr_length, buffer, length);
1006 | rr->bytes_parsed += 1;
1007 | bytes_parsed += 1;
1008 | advancexb(naptr_length, buffer, length);
1009 | rr->bytes_parsed += naptr_length;
1010 | bytes_parsed += naptr_length;
1011 |
1012 | need8(naptr_length, buffer, length);
1013 | rr->bytes_parsed += 1;
1014 | bytes_parsed += 1;
1015 | advancexb(naptr_length, buffer, length);
1016 | rr->bytes_parsed += naptr_length;
1017 | bytes_parsed += naptr_length;
1018 | } break;
1019 |
1020 | case OMG_DNS_TYPE_HIP: {
1021 | uint8_t hit_length;
1022 | uint16_t pk_length;
1023 |
1024 | need8(hit_length, buffer, length);
1025 | rr->bytes_parsed += 1;
1026 | bytes_parsed += 1;
1027 |
1028 | advancexb(1, buffer, length);
1029 | rr->bytes_parsed += 1;
1030 | bytes_parsed += 1;
1031 |
1032 | need16(pk_length, buffer, length);
1033 | rr->bytes_parsed += 2;
1034 | bytes_parsed += 2;
1035 |
1036 | advancexb(hit_length, buffer, length);
1037 | rr->bytes_parsed += hit_length;
1038 | bytes_parsed += hit_length;
1039 |
1040 | advancexb(pk_length, buffer, length);
1041 | rr->bytes_parsed += pk_length;
1042 | bytes_parsed += pk_length;
1043 |
1044 | if (rr->bytes_parsed >= rr->rdlength)
1045 | labels = 0;
1046 | } break;
1047 | }
1048 |
1049 | while (labels) {
1050 | omg_dns_label_t label = OMG_DNS_LABEL_T_INIT;
1051 |
1052 | label._offset = rr->_offset + rr->bytes_parsed;
1053 | need8(label.length, buffer, length);
1054 | rr->bytes_parsed += 1;
1055 | bytes_parsed += 1;
1056 |
1057 | if ((label.length & 0xc0) == 0xc0) {
1058 | need8(label.offset, buffer, length);
1059 | label.offset |= (label.length & 0x3f) << 8;
1060 | rr->bytes_parsed += 1;
1061 | bytes_parsed += 1;
1062 | label.have_offset = 1;
1063 |
1064 | label.is_complete = 1;
1065 | if (rr->label_callback) {
1066 | ret = rr->label_callback(&label, rr->label_callback_context);
1067 | if (ret != OMG_DNS_OK)
1068 | return ret;
1069 | }
1070 | rr->rdata_labels++;
1071 | labels--;
1072 | if (rr->type == OMG_DNS_TYPE_HIP && rr->bytes_parsed < rr->rdlength)
1073 | labels++;
1074 | continue;
1075 | } else if (label.length & 0xc0) {
1076 | label.extension_bits = label.length >> 6;
1077 | label.have_extension_bits = 1;
1078 |
1079 | label.is_complete = 1;
1080 | if (rr->label_callback) {
1081 | ret = rr->label_callback(&label, rr->label_callback_context);
1082 | if (ret != OMG_DNS_OK)
1083 | return ret;
1084 | }
1085 | rr->rdata_labels++;
1086 | labels--;
1087 | if (rr->type == OMG_DNS_TYPE_HIP && rr->bytes_parsed < rr->rdlength)
1088 | labels++;
1089 | continue;
1090 | } else if (label.length) {
1091 | label.have_length = 1;
1092 |
1093 | label.offset = label._offset;
1094 | label.dn_offset = label._offset + 1;
1095 | advancexb(label.length, buffer, length);
1096 | rr->bytes_parsed += label.length;
1097 | bytes_parsed += label.length;
1098 | label.have_dn = 1;
1099 |
1100 | label.is_complete = 1;
1101 | if (rr->label_callback) {
1102 | ret = rr->label_callback(&label, rr->label_callback_context);
1103 | if (ret != OMG_DNS_OK)
1104 | return ret;
1105 | }
1106 | rr->rdata_labels++;
1107 | } else {
1108 | label.is_end = 1;
1109 | label.is_complete = 1;
1110 | if (rr->label_callback) {
1111 | ret = rr->label_callback(&label, rr->label_callback_context);
1112 | if (ret != OMG_DNS_OK)
1113 | return ret;
1114 | }
1115 | labels--;
1116 | if (rr->type == OMG_DNS_TYPE_HIP && rr->bytes_parsed < rr->rdlength)
1117 | labels++;
1118 | continue;
1119 | }
1120 | }
1121 | rr->have_rdata_labels = 1;
1122 |
1123 | if (bytes_parsed < rr->rdlength) {
1124 | rr->padding_offset = rr->rdata_offset + bytes_parsed;
1125 | rr->padding_length = rr->rdlength - bytes_parsed;
1126 |
1127 | advancexb(rr->padding_length, buffer, length);
1128 | rr->bytes_parsed += rr->padding_length;
1129 |
1130 | /*
1131 | * TODO:
1132 | *
1133 | * This can indicate padding but we do not set that we have padding
1134 | * yet because we need to fully understand all record types before
1135 | * that and process valid data after the labels
1136 | *
1137 | rr->have_padding = 1;
1138 | */
1139 | } else if (bytes_parsed > rr->rdlength) {
1140 | return OMG_DNS_EOVERRUN;
1141 | }
1142 |
1143 | rr->have_rdata = 1;
1144 | } else {
1145 | advancexb(rr->rdlength, buffer, length);
1146 | rr->bytes_parsed += rr->rdlength;
1147 | rr->have_rdata = 1;
1148 | }
1149 |
1150 | rr->is_complete = 1;
1151 |
1152 | return OMG_DNS_OK;
1153 | }
1154 |
--------------------------------------------------------------------------------
/omg_dns.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Author Jerry Lundström
3 | * Copyright (c) 2017, OARC, Inc.
4 | * All rights reserved.
5 | *
6 | * This file is part of omg-dns.
7 | *
8 | * omg-dns is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * omg-dns is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with omg-dns. If not, see .
20 | */
21 |
22 | #ifndef __omg_dns_h
23 | #define __omg_dns_h
24 |
25 | #include
26 | #if OMG_DNS_ENABLE_ASSERT
27 | #include
28 | #define omg_dns_assert(x) assert(x)
29 | #else
30 | #define omg_dns_assert(x)
31 | #endif
32 |
33 | /* clang-format off */
34 |
35 | #define OMG_DNS_VERSION_STR "1.0.0"
36 | #define OMG_DNS_VERSION_MAJOR 1
37 | #define OMG_DNS_VERSION_MINOR 0
38 | #define OMG_DNS_VERSION_PATCH 0
39 |
40 | #define OMG_DNS_OK 0
41 | #define OMG_DNS_EINVAL 1
42 | #define OMG_DNS_EINCOMP 2
43 | #define OMG_DNS_ENOMEM 3
44 | #define OMG_DNS_EOVERRUN 4
45 |
46 | /* clang-format on */
47 |
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | const char* omg_dns_version_str(void);
53 | int omg_dns_version_major(void);
54 | int omg_dns_version_minor(void);
55 | int omg_dns_version_patch(void);
56 |
57 | /* clang-format off */
58 | #define OMG_DNS_LABEL_T_INIT { \
59 | 0, \
60 | 0, \
61 | 0,0,0,0, 0, \
62 | 0, 0, 0, 0 \
63 | }
64 | /* clang-format on */
65 |
66 | typedef struct omg_dns_label omg_dns_label_t;
67 | struct omg_dns_label {
68 | size_t _offset;
69 |
70 | unsigned short is_end : 1;
71 |
72 | unsigned short have_length : 1;
73 | unsigned short have_offset : 1;
74 | unsigned short have_extension_bits : 1;
75 | unsigned short have_dn : 1;
76 |
77 | unsigned short is_complete : 1;
78 |
79 | uint8_t length;
80 | uint16_t offset;
81 | unsigned short extension_bits : 2;
82 | size_t dn_offset;
83 | };
84 |
85 | int omg_dns_label_is_end(const omg_dns_label_t* label);
86 | int omg_dns_label_have_length(const omg_dns_label_t* label);
87 | int omg_dns_label_have_offset(const omg_dns_label_t* label);
88 | int omg_dns_label_have_extension_bits(const omg_dns_label_t* label);
89 | int omg_dns_label_have_dn(const omg_dns_label_t* label);
90 | int omg_dns_label_is_complete(const omg_dns_label_t* label);
91 |
92 | uint8_t omg_dns_label_length(const omg_dns_label_t* label);
93 | uint16_t omg_dns_label_offset(const omg_dns_label_t* label);
94 | unsigned short omg_dns_label_extension_bits(const omg_dns_label_t* label);
95 | size_t omg_dns_label_dn_offset(const omg_dns_label_t* label);
96 |
97 | typedef int (*omg_dns_label_callback_t)(const omg_dns_label_t* label, void* context);
98 |
99 | /* clang-format off */
100 | #define OMG_DNS_RR_T_INIT { \
101 | 0, \
102 | 0,0, \
103 | 0, \
104 | 0, \
105 | 0,0,0,0,0,0,0, \
106 | 0,0, \
107 | 0, \
108 | 0,0,0,0,0,0,0,0, \
109 | }
110 | /* clang-format on */
111 |
112 | typedef struct omg_dns_rr omg_dns_rr_t;
113 | struct omg_dns_rr {
114 | size_t _offset;
115 |
116 | omg_dns_label_callback_t label_callback;
117 | void* label_callback_context;
118 |
119 | unsigned short is_question : 1;
120 |
121 | unsigned short have_labels : 1;
122 |
123 | unsigned short have_type : 1;
124 | unsigned short have_class : 1;
125 | unsigned short have_ttl : 1;
126 | unsigned short have_rdlength : 1;
127 | unsigned short have_rdata : 1;
128 | unsigned short have_rdata_labels : 1;
129 | unsigned short have_padding : 1;
130 |
131 | unsigned short is_complete : 1;
132 | size_t bytes_parsed;
133 |
134 | size_t labels;
135 |
136 | uint16_t type;
137 | uint16_t class;
138 | uint32_t ttl;
139 | uint16_t rdlength;
140 | size_t rdata_offset;
141 | size_t rdata_labels;
142 | size_t padding_offset;
143 | size_t padding_length;
144 | };
145 |
146 | omg_dns_label_callback_t omg_dns_rr_label_callback(const omg_dns_rr_t* rr);
147 | void* omg_dns_rr_label_callback_context(const omg_dns_rr_t* rr);
148 | void omg_dns_rr_set_label_callback(omg_dns_rr_t* rr, omg_dns_label_callback_t label_callback, void* label_callback_context);
149 |
150 | int omg_dns_rr_is_question(const omg_dns_rr_t* rr);
151 | int omg_dns_rr_have_labels(const omg_dns_rr_t* rr);
152 | int omg_dns_rr_have_type(const omg_dns_rr_t* rr);
153 | int omg_dns_rr_have_class(const omg_dns_rr_t* rr);
154 | int omg_dns_rr_have_ttl(const omg_dns_rr_t* rr);
155 | int omg_dns_rr_have_rdlength(const omg_dns_rr_t* rr);
156 | int omg_dns_rr_have_rdata(const omg_dns_rr_t* rr);
157 | int omg_dns_rr_have_rdata_labels(const omg_dns_rr_t* rr);
158 | int omg_dns_rr_have_padding(const omg_dns_rr_t* rr);
159 | int omg_dns_rr_is_complete(const omg_dns_rr_t* rr);
160 |
161 | size_t omg_dns_rr_bytes_parsed(const omg_dns_rr_t* rr);
162 |
163 | size_t omg_dns_rr_labels(const omg_dns_rr_t* rr);
164 | uint16_t omg_dns_rr_type(const omg_dns_rr_t* rr);
165 | uint16_t omg_dns_rr_class(const omg_dns_rr_t* rr);
166 | uint32_t omg_dns_rr_ttl(const omg_dns_rr_t* rr);
167 | uint16_t omg_dns_rr_rdlength(const omg_dns_rr_t* rr);
168 | size_t omg_dns_rr_rdata_offset(const omg_dns_rr_t* rr);
169 | size_t omg_dns_rr_rdata_labels(const omg_dns_rr_t* rr);
170 | size_t omg_dns_rr_padding_offset(const omg_dns_rr_t* rr);
171 | size_t omg_dns_rr_padding_length(const omg_dns_rr_t* rr);
172 | size_t omg_dns_rr_num_rdata_labels(const omg_dns_rr_t* rr);
173 |
174 | typedef int (*omg_dns_rr_callback_t)(int ret, const omg_dns_rr_t* rr, void* context);
175 |
176 | /* clang-format off */
177 | #define OMG_DNS_T_INIT { \
178 | 0,0, 0,0, \
179 | 0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0, 0,0,0,0, 0, \
180 | 0,0,0,0, \
181 | 0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 \
182 | }
183 | /* clang-format on */
184 |
185 | typedef struct omg_dns omg_dns_t;
186 | struct omg_dns {
187 | omg_dns_label_callback_t label_callback;
188 | void* label_callback_context;
189 |
190 | omg_dns_rr_callback_t rr_callback;
191 | void* rr_callback_context;
192 |
193 | unsigned short have_id : 1;
194 |
195 | unsigned short have_qr : 1;
196 | unsigned short have_opcode : 1;
197 | unsigned short have_aa : 1;
198 | unsigned short have_tc : 1;
199 | unsigned short have_rd : 1;
200 |
201 | unsigned short have_ra : 1;
202 | unsigned short have_z : 1;
203 | unsigned short have_ad : 1;
204 | unsigned short have_cd : 1;
205 | unsigned short have_rcode : 1;
206 |
207 | unsigned short have_qdcount : 1;
208 | unsigned short have_ancount : 1;
209 | unsigned short have_nscount : 1;
210 | unsigned short have_arcount : 1;
211 |
212 | unsigned short have_questions : 1;
213 | unsigned short have_answers : 1;
214 | unsigned short have_authorities : 1;
215 | unsigned short have_additionals : 1;
216 |
217 | unsigned short have_padding : 1;
218 |
219 | unsigned short have_header : 1;
220 | unsigned short have_body : 1;
221 | unsigned short is_complete : 1;
222 | size_t bytes_parsed;
223 |
224 | uint16_t id;
225 |
226 | unsigned short qr : 1;
227 | unsigned short opcode : 4;
228 | unsigned short aa : 1;
229 | unsigned short tc : 1;
230 | unsigned short rd : 1;
231 |
232 | unsigned short ra : 1;
233 | unsigned short z : 1;
234 | unsigned short ad : 1;
235 | unsigned short cd : 1;
236 | unsigned short rcode : 4;
237 |
238 | uint16_t qdcount;
239 | uint16_t ancount;
240 | uint16_t nscount;
241 | uint16_t arcount;
242 |
243 | size_t questions;
244 | size_t answers;
245 | size_t authorities;
246 | size_t additionals;
247 |
248 | size_t padding_offset;
249 | size_t padding_length;
250 | };
251 |
252 | omg_dns_label_callback_t omg_dns_label_callback(const omg_dns_t* dns);
253 | void* omg_dns_label_callback_context(const omg_dns_t* dns);
254 | void omg_dns_set_label_callback(omg_dns_t* dns, omg_dns_label_callback_t label_callback, void* label_callback_context);
255 |
256 | omg_dns_rr_callback_t omg_dns_rr_callback(const omg_dns_t* dns);
257 | void* omg_dns_rr_callback_context(const omg_dns_t* dns);
258 | void omg_dns_set_rr_callback(omg_dns_t* dns, omg_dns_rr_callback_t rr_callback, void* rr_callback_context);
259 |
260 | int omg_dns_have_id(const omg_dns_t* dns);
261 | int omg_dns_have_qr(const omg_dns_t* dns);
262 | int omg_dns_have_opcode(const omg_dns_t* dns);
263 | int omg_dns_have_aa(const omg_dns_t* dns);
264 | int omg_dns_have_tc(const omg_dns_t* dns);
265 | int omg_dns_have_rd(const omg_dns_t* dns);
266 | int omg_dns_have_ra(const omg_dns_t* dns);
267 | int omg_dns_have_z(const omg_dns_t* dns);
268 | int omg_dns_have_ad(const omg_dns_t* dns);
269 | int omg_dns_have_cd(const omg_dns_t* dns);
270 | int omg_dns_have_rcode(const omg_dns_t* dns);
271 | int omg_dns_have_qdcount(const omg_dns_t* dns);
272 | int omg_dns_have_ancount(const omg_dns_t* dns);
273 | int omg_dns_have_nscount(const omg_dns_t* dns);
274 | int omg_dns_have_arcount(const omg_dns_t* dns);
275 | int omg_dns_have_questions(const omg_dns_t* dns);
276 | int omg_dns_have_answers(const omg_dns_t* dns);
277 | int omg_dns_have_authorities(const omg_dns_t* dns);
278 | int omg_dns_have_additionals(const omg_dns_t* dns);
279 | int omg_dns_have_padding(const omg_dns_t* dns);
280 | int omg_dns_have_header(const omg_dns_t* dns);
281 | int omg_dns_have_body(const omg_dns_t* dns);
282 | int omg_dns_is_complete(const omg_dns_t* dns);
283 |
284 | size_t omg_dns_bytes_parsed(const omg_dns_t* dns);
285 |
286 | uint16_t omg_dns_id(const omg_dns_t* dns);
287 | int omg_dns_qr(const omg_dns_t* dns);
288 | int omg_dns_opcode(const omg_dns_t* dns);
289 | int omg_dns_aa(const omg_dns_t* dns);
290 | int omg_dns_tc(const omg_dns_t* dns);
291 | int omg_dns_rd(const omg_dns_t* dns);
292 | int omg_dns_ra(const omg_dns_t* dns);
293 | int omg_dns_z(const omg_dns_t* dns);
294 | int omg_dns_ad(const omg_dns_t* dns);
295 | int omg_dns_cd(const omg_dns_t* dns);
296 | int omg_dns_rcode(const omg_dns_t* dns);
297 | uint16_t omg_dns_qdcount(const omg_dns_t* dns);
298 | uint16_t omg_dns_ancount(const omg_dns_t* dns);
299 | uint16_t omg_dns_nscount(const omg_dns_t* dns);
300 | uint16_t omg_dns_arcount(const omg_dns_t* dns);
301 | size_t omg_dns_questions(const omg_dns_t* dns);
302 | size_t omg_dns_answers(const omg_dns_t* dns);
303 | size_t omg_dns_authorities(const omg_dns_t* dns);
304 | size_t omg_dns_additionals(const omg_dns_t* dns);
305 | size_t omg_dns_padding_offset(const omg_dns_t* dns);
306 | size_t omg_dns_padding_length(const omg_dns_t* dns);
307 |
308 | int omg_dns_parse_header(omg_dns_t* dns, const uint8_t* buffer, size_t length);
309 | int omg_dns_parse_body(omg_dns_t* dns, const uint8_t* buffer, size_t length);
310 | int omg_dns_parse(omg_dns_t* dns, const uint8_t* buffer, size_t length);
311 | int omg_dns_parse_rr(omg_dns_rr_t* rr, const uint8_t* buffer, size_t length);
312 |
313 | #ifdef __cplusplus
314 | }
315 | #endif
316 |
317 | /*
318 | * 2016-12-09 https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml
319 | */
320 |
321 | #define OMG_DNS_CLASS_IN 1
322 | #define OMG_DNS_CLASS_CH 3
323 | #define OMG_DNS_CLASS_HS 4
324 | #define OMG_DNS_CLASS_NONE 254
325 | #define OMG_DNS_CLASS_ANY 255
326 |
327 | #define OMG_DNS_TYPE_A 1
328 | #define OMG_DNS_TYPE_NS 2
329 | #define OMG_DNS_TYPE_MD 3
330 | #define OMG_DNS_TYPE_MF 4
331 | #define OMG_DNS_TYPE_CNAME 5
332 | #define OMG_DNS_TYPE_SOA 6
333 | #define OMG_DNS_TYPE_MB 7
334 | #define OMG_DNS_TYPE_MG 8
335 | #define OMG_DNS_TYPE_MR 9
336 | #define OMG_DNS_TYPE_NULL 10
337 | #define OMG_DNS_TYPE_WKS 11
338 | #define OMG_DNS_TYPE_PTR 12
339 | #define OMG_DNS_TYPE_HINFO 13
340 | #define OMG_DNS_TYPE_MINFO 14
341 | #define OMG_DNS_TYPE_MX 15
342 | #define OMG_DNS_TYPE_TXT 16
343 | #define OMG_DNS_TYPE_RP 17
344 | #define OMG_DNS_TYPE_AFSDB 18
345 | #define OMG_DNS_TYPE_X25 19
346 | #define OMG_DNS_TYPE_ISDN 20
347 | #define OMG_DNS_TYPE_RT 21
348 | #define OMG_DNS_TYPE_NSAP 22
349 | #define OMG_DNS_TYPE_NSAP_PTR 23
350 | #define OMG_DNS_TYPE_SIG 24
351 | #define OMG_DNS_TYPE_KEY 25
352 | #define OMG_DNS_TYPE_PX 26
353 | #define OMG_DNS_TYPE_GPOS 27
354 | #define OMG_DNS_TYPE_AAAA 28
355 | #define OMG_DNS_TYPE_LOC 29
356 | #define OMG_DNS_TYPE_NXT 30
357 | #define OMG_DNS_TYPE_EID 31
358 | #define OMG_DNS_TYPE_NIMLOC 32
359 | #define OMG_DNS_TYPE_SRV 33
360 | #define OMG_DNS_TYPE_ATMA 34
361 | #define OMG_DNS_TYPE_NAPTR 35
362 | #define OMG_DNS_TYPE_KX 36
363 | #define OMG_DNS_TYPE_CERT 37
364 | #define OMG_DNS_TYPE_A6 38
365 | #define OMG_DNS_TYPE_DNAME 39
366 | #define OMG_DNS_TYPE_SINK 40
367 | #define OMG_DNS_TYPE_OPT 41
368 | #define OMG_DNS_TYPE_APL 42
369 | #define OMG_DNS_TYPE_DS 43
370 | #define OMG_DNS_TYPE_SSHFP 44
371 | #define OMG_DNS_TYPE_IPSECKEY 45
372 | #define OMG_DNS_TYPE_RRSIG 46
373 | #define OMG_DNS_TYPE_NSEC 47
374 | #define OMG_DNS_TYPE_DNSKEY 48
375 | #define OMG_DNS_TYPE_DHCID 49
376 | #define OMG_DNS_TYPE_NSEC3 50
377 | #define OMG_DNS_TYPE_NSEC3PARAM 51
378 | #define OMG_DNS_TYPE_TLSA 52
379 | #define OMG_DNS_TYPE_SMIMEA 53
380 | #define OMG_DNS_TYPE_HIP 55
381 | #define OMG_DNS_TYPE_NINFO 56
382 | #define OMG_DNS_TYPE_RKEY 57
383 | #define OMG_DNS_TYPE_TALINK 58
384 | #define OMG_DNS_TYPE_CDS 59
385 | #define OMG_DNS_TYPE_CDNSKEY 60
386 | #define OMG_DNS_TYPE_OPENPGPKEY 61
387 | #define OMG_DNS_TYPE_CSYNC 62
388 | #define OMG_DNS_TYPE_SPF 99
389 | #define OMG_DNS_TYPE_UINFO 100
390 | #define OMG_DNS_TYPE_UID 101
391 | #define OMG_DNS_TYPE_GID 102
392 | #define OMG_DNS_TYPE_UNSPEC 103
393 | #define OMG_DNS_TYPE_NID 104
394 | #define OMG_DNS_TYPE_L32 105
395 | #define OMG_DNS_TYPE_L64 106
396 | #define OMG_DNS_TYPE_LP 107
397 | #define OMG_DNS_TYPE_EUI48 108
398 | #define OMG_DNS_TYPE_EUI64 109
399 | #define OMG_DNS_TYPE_TKEY 249
400 | #define OMG_DNS_TYPE_TSIG 250
401 | #define OMG_DNS_TYPE_IXFR 251
402 | #define OMG_DNS_TYPE_AXFR 252
403 | #define OMG_DNS_TYPE_MAILB 253
404 | #define OMG_DNS_TYPE_MAILA 254
405 | #define OMG_DNS_TYPE_ANY 255
406 | #define OMG_DNS_TYPE_URI 256
407 | #define OMG_DNS_TYPE_CAA 257
408 | #define OMG_DNS_TYPE_AVC 258
409 | #define OMG_DNS_TYPE_TA 32768
410 | #define OMG_DNS_TYPE_DLV 32769
411 |
412 | #define OMG_DNS_OPCODE_QUERY 0
413 | #define OMG_DNS_OPCODE_IQUERY 1
414 | #define OMG_DNS_OPCODE_STATUS 2
415 | #define OMG_DNS_OPCODE_NOTIFY 4
416 | #define OMG_DNS_OPCODE_UPDATE 5
417 |
418 | #define OMG_DNS_RCODE_NOERROR 0
419 | #define OMG_DNS_RCODE_FORMERR 1
420 | #define OMG_DNS_RCODE_SERVFAIL 2
421 | #define OMG_DNS_RCODE_NXDOMAIN 3
422 | #define OMG_DNS_RCODE_NOTIMP 4
423 | #define OMG_DNS_RCODE_REFUSED 5
424 | #define OMG_DNS_RCODE_YXDOMAIN 6
425 | #define OMG_DNS_RCODE_YXRRSET 7
426 | #define OMG_DNS_RCODE_NXRRSET 8
427 | #define OMG_DNS_RCODE_NOTAUTH 9
428 | #define OMG_DNS_RCODE_NOTZONE 10
429 | #define OMG_DNS_RCODE_BADVERS 16
430 | #define OMG_DNS_RCODE_BADSIG 16
431 | #define OMG_DNS_RCODE_BADKEY 17
432 | #define OMG_DNS_RCODE_BADTIME 18
433 | #define OMG_DNS_RCODE_BADMODE 19
434 | #define OMG_DNS_RCODE_BADNAME 20
435 | #define OMG_DNS_RCODE_BADALG 21
436 | #define OMG_DNS_RCODE_BADTRUNC 22
437 | #define OMG_DNS_RCODE_BADCOOKIE 23
438 |
439 | #define OMG_DNS_AFSDB_SUBTYPE_AFS3LOCSRV 1
440 | #define OMG_DNS_AFSDB_SUBTYPE_DCENCA_ROOT 2
441 |
442 | #define OMG_DNS_DHCID_TYPE_1OCTET 0
443 | #define OMG_DNS_DHCID_TYPE_DATAOCTET 1
444 | #define OMG_DNS_DHCID_TYPE_CLIENT_DUID 2
445 |
446 | #define OMG_DNS_EDNS0_OPT_LLQ 1
447 | #define OMG_DNS_EDNS0_OPT_UL 2
448 | #define OMG_DNS_EDNS0_OPT_NSID 3
449 | #define OMG_DNS_EDNS0_OPT_DAU 5
450 | #define OMG_DNS_EDNS0_OPT_DHU 6
451 | #define OMG_DNS_EDNS0_OPT_N3U 7
452 | #define OMG_DNS_EDNS0_OPT_CLIENT_SUBNET 8
453 | #define OMG_DNS_EDNS0_OPT_EXPIRE 9
454 | #define OMG_DNS_EDNS0_OPT_COOKIE 10
455 | #define OMG_DNS_EDNS0_OPT_TCP_KEEPALIVE 11
456 | #define OMG_DNS_EDNS0_OPT_PADDING 12
457 | #define OMG_DNS_EDNS0_OPT_CHAIN 13
458 | #define OMG_DNS_EDNS0_OPT_DEVICEID 26946
459 |
460 | #endif /* __omg_dns_h */
461 |
--------------------------------------------------------------------------------