2024-06-12 03:57:17 +00:00
|
|
|
#pragma once
|
2024-06-12 03:40:41 +00:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <linux/limits.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2024-06-19 10:49:21 +00:00
|
|
|
#define DNS_MESSAGE_TOPIC "TOPIC_DNS_MESSAGE"
|
2024-06-12 03:40:41 +00:00
|
|
|
|
|
|
|
|
struct dns_message;
|
2024-06-19 10:49:21 +00:00
|
|
|
struct dns_query_question;
|
|
|
|
|
struct dns_resource_record;
|
2024-06-12 03:40:41 +00:00
|
|
|
|
|
|
|
|
/*.
|
|
|
|
|
First call DNS_MESSAGE_TRANSACTION_BEGIN to create the transaction,
|
|
|
|
|
then publish the transaction's DNS_MESSAGE_QUERY/DNS_MESSAGE_RESPONSE,
|
|
|
|
|
and finally call DNS_MESSAGE_TRANSACTION_END to release the transaction.
|
|
|
|
|
*/
|
|
|
|
|
enum dns_message_type
|
|
|
|
|
{
|
|
|
|
|
DNS_MESSAGE_QUERY=1,
|
|
|
|
|
DNS_MESSAGE_RESPONSE,
|
|
|
|
|
DNS_MESSAGE_TRANSACTION_BEGIN,
|
|
|
|
|
DNS_MESSAGE_TRANSACTION_END,
|
|
|
|
|
DNS_MESSAGE_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum dns_message_type dns_message_type_get(struct dns_message *msg);
|
|
|
|
|
|
|
|
|
|
struct dns_flag
|
|
|
|
|
{
|
|
|
|
|
uint8_t qr:1;
|
|
|
|
|
uint8_t opcode:4;
|
|
|
|
|
uint8_t aa:1;
|
|
|
|
|
uint8_t tc:1;
|
|
|
|
|
uint8_t rd:1;
|
|
|
|
|
uint8_t ra:1;
|
|
|
|
|
uint8_t z:3;
|
|
|
|
|
uint8_t rcode:4;
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-12 14:46:15 +00:00
|
|
|
int32_t dns_message_transaction_index_get(struct dns_message *msg);
|
|
|
|
|
|
2024-06-12 03:40:41 +00:00
|
|
|
int32_t dns_message_header_id_get(struct dns_message *msg);
|
|
|
|
|
struct dns_flag *dns_message_header_flag_get0(struct dns_message *msg);
|
2024-06-19 10:49:21 +00:00
|
|
|
|
|
|
|
|
void dns_message_query_question_get0(struct dns_message *msg, struct dns_query_question **question, uint16_t *n_question);
|
|
|
|
|
const char *dns_query_question_qname_get0(struct dns_query_question *question);
|
|
|
|
|
int32_t dns_query_question_qtype_get0(struct dns_query_question *question);
|
|
|
|
|
int32_t dns_query_question_qclass_get0(struct dns_query_question *question);
|
|
|
|
|
|
2024-06-12 03:40:41 +00:00
|
|
|
void dns_message_answer_resource_record_get0(struct dns_message *msg, struct dns_resource_record **answer_rr, uint16_t *n_answer_rr);
|
|
|
|
|
void dns_message_authority_resource_record_get0(struct dns_message *msg, struct dns_resource_record **authority_rr, uint16_t *n_authority_rr);
|
|
|
|
|
void dns_message_additional_resource_record_get0(struct dns_message *msg, struct dns_resource_record **additional_rr, uint16_t *n_additional_rr);
|
|
|
|
|
|
2024-06-19 10:49:21 +00:00
|
|
|
const char *dns_resource_record_json_exporter(struct dns_resource_record *rr_array, uint16_t n_rr);
|
|
|
|
|
|
2024-06-12 03:40:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|