{"id":21377249,"url":"https://github.com/dns-oarc/omg-dns","last_synced_at":"2025-07-04T11:35:30.284Z","repository":{"id":50146758,"uuid":"77610078","full_name":"DNS-OARC/omg-dns","owner":"DNS-OARC","description":"Helper library for parsing valid/invalid/broken/malformed DNS packets","archived":false,"fork":false,"pushed_at":"2021-06-02T14:02:01.000Z","size":50,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-06-16T07:50:29.758Z","etag":null,"topics":["c","dns","dns-record","dns-rfcs","library","parsing"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DNS-OARC.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-29T12:17:25.000Z","updated_at":"2024-08-21T09:28:12.000Z","dependencies_parsed_at":"2022-08-27T08:01:02.021Z","dependency_job_id":null,"html_url":"https://github.com/DNS-OARC/omg-dns","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/DNS-OARC/omg-dns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fomg-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fomg-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fomg-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fomg-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DNS-OARC","download_url":"https://codeload.github.com/DNS-OARC/omg-dns/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fomg-dns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263502344,"owners_count":23476571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","dns","dns-record","dns-rfcs","library","parsing"],"created_at":"2024-11-22T09:19:44.570Z","updated_at":"2025-07-04T11:35:30.237Z","avatar_url":"https://github.com/DNS-OARC.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# omg-dns\n\nHelper library for parsing valid/invalid/broken/malformed DNS packets\n\n## About\n\nThis is a helper library intended to be included within other projects\nrepositories as a submodule to help them parse DNS packets.  It will parse\nas much as possible and will indicate where and what failed if any.\n\nSupported RFCs:\n- todo\n\n## Usage\n\nHere is a short example how to use this library, for a more complete program\ncheck `hexdns2text/hexdns2text.c`.\n\n```c\n#include \"omg-dns/omg_dns.h\"\n#include \u003cstdio.h\u003e\n\nstruct context {\n    size_t num_rr;\n    size_t num_label;\n};\n\nstatic int label_callback(const omg_dns_label_t* label, void* vp) {\n    struct context* context = (struct context*)vp;\n\n    printf(\"  label %lu:\\n\", context-\u003enum_label++);\n    if (omg_dns_label_is_end(label))\n        printf(\"    end: yes\\n\");\n    else if (!omg_dns_label_is_complete(label))\n        printf(\"    incomplete: yes\\n\");\n    else if (omg_dns_label_have_offset(label))\n        printf(\"    offset: %d\\n\", omg_dns_label_offset(label));\n    else if (omg_dns_label_have_extension_bits(label))\n        printf(\"    extension_bits: %02x\\n\", omg_dns_label_extension_bits(label));\n\n    return OMG_DNS_OK;\n}\n\nstatic int rr_callback(int ret, const omg_dns_rr_t* rr, void* vp) {\n    struct context* context = (struct context*)vp;\n\n    printf(\"  rr %lu:\\n\", context-\u003enum_rr++);\n    printf(\"    question: %s\\n\", omg_dns_rr_is_question(rr) ? \"yes\" : \"no\");\n    if (omg_dns_rr_have_type(rr))\n        printf(\"    type: %u\\n\", omg_dns_rr_type(rr));\n\n    return OMG_DNS_OK;\n}\n\nint main(void) {\n    omg_dns_t dns = OMG_DNS_T_INIT;\n    struct context context = { 0, 0 };\n    uint8_t packet[] = { ... raw dns packet as byte array ... };\n\n    omg_dns_set_rr_callback(\u0026dns, rr_callback, (void*)\u0026context);\n    omg_dns_set_label_callback(\u0026dns, label_callback, (void*)\u0026context);\n    omg_dns_parse(\u0026dns, packet, sizeof(packet));\n\n    if (omg_dns_have_id(\u0026dns))\n        printf(\"id: %u\\n\", omg_dns_id(\u0026dns));\n\n    return 0;\n}\n```\n\n### git submodule\n\n```shell\ngit submodule init\ngit submodule add https://github.com/DNS-OARC/omg-dns.git src/omg-dns\n```\n\n### Makefile.am\n\n```m4\nprogram_SOURCES += omg-dns/omg_dns.c\ndist_program_SOURCES += omg-dns/omg_dns.h\n```\n\n## Author(s)\n\nJerry Lundström \u003cjerry@dns-oarc.net\u003e\n\n## Copyright\n\nCopyright (c) 2017, OARC, Inc.\nAll rights reserved.\n\nThis file is part of omg-dns.\n\nomg-dns is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nomg-dns is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with omg-dns.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdns-oarc%2Fomg-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdns-oarc%2Fomg-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdns-oarc%2Fomg-dns/lists"}