Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_dns.c File Reference

Minimal DNS message helpers implementation. More...

#include "nilorea/n_dns.h"
#include <string.h>
+ Include dependency graph for n_dns.c:

Go to the source code of this file.

Macros

#define N_DNS_HEADER_LEN   12
 DNS header size in bytes (id, flags, and the four section counts).
 

Functions

int n_dns_build_a_response (const unsigned char *query, size_t qlen, uint32_t ipv4_be, uint32_t ttl, unsigned char *out, size_t outsz)
 Build a DNS response answering a query's first question with one A record.
 
int n_dns_parse_query (const unsigned char *msg, size_t len, uint16_t *id_out, char *qname_out, size_t qname_sz, uint16_t *qtype_out)
 Parse the header id and the first question (QNAME + QTYPE) of a DNS message.
 
static uint16_t n_dns_u16 (const unsigned char *msg, size_t off)
 

Detailed Description

Minimal DNS message helpers implementation.

Author
Castagnier Mickael
Version
1.0

Definition in file n_dns.c.

Macro Definition Documentation

◆ N_DNS_HEADER_LEN

#define N_DNS_HEADER_LEN   12

DNS header size in bytes (id, flags, and the four section counts).

Definition at line 32 of file n_dns.c.

Function Documentation

◆ n_dns_u16()

static uint16_t n_dns_u16 ( const unsigned char *  msg,
size_t  off 
)
static

Definition at line 35 of file n_dns.c.

Referenced by n_dns_build_a_response(), and n_dns_parse_query().

+ Here is the caller graph for this function: