6 n__dns_8h
gullradriel edited this page 2026-10-09 00:55:18 +02:00

include/nilorea/n_dns.h

Minimal DNS message helpers: parse a query question and build an A-record response. More...

Detailed Description

Minimal DNS message helpers: parse a query question and build an A-record response.

Author: Castagnier Mickael

Version: 1.0

Source code

/*
 * Nilorea Library
 * Copyright (C) 2005-2026 Castagnier Mickael
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef __NILOREA_DNS_HEADER
#define __NILOREA_DNS_HEADER

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>
#include <stdint.h>


#define N_DNS_QNAME_MAX 256
#define N_DNS_TYPE_A 1

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);

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);


#ifdef __cplusplus
}
#endif

#endif /* __NILOREA_DNS_HEADER */