Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bughandler/libdnspacket

A single file cpp17 header only DNS packet parser/builder.
https://github.com/bughandler/libdnspacket

cpp17 dns parser

Last synced: about 2 months ago
JSON representation

A single file cpp17 header only DNS packet parser/builder.

Awesome Lists containing this project

README

        

# libdnspacket
An ultra lightweight, cross platform and single header DNS packet parser & builder.

+ Easy to use

+ No external dependency

+ Parse DNS packet

+ Build DNS packet

+ DNS host name compression

+ Support multiple DNS record types

> + A
> + NS
> + CNAME
> + SOA
> + PTR
> + MX
> + TXT
> + AAAA
> + SPF

### How to use

1. Just copy `libdnspacket` into your project folder
2. Include `libdnspacket/dns.hpp`
3. You are ready to go

### APIs

​ There are two simple APIs.

+ Parse raw DNS packet into DNS message

``` c++
//
// Parameters:
// buf: point to the raw DNS packet
// bufSize: indicate the size of [buf]
// Return:
//
// #1: indicate whether the packet was parsed successfully or not
// #2: when #1 value is true, this is the final structured DNS message
//
std::tuple dns::Parse(const uint8_t* buf, size_t bufSize);
```

+ Build raw DNS packet from DNS message

``` c++
//
// Parameters:
// message: the structured DNS message
// Return:
// The byte buffer of raw DNS packet
//
std::vector dns::Build(const DnsMessage& message);
```

### Notes

+ Any feedback is welcome