mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-18 15:49:56 +00:00
dns_txt: Add TXT record parsing support
Change-Id: Ie0eca23b8e6f4c7d9846b6013d79099314d90ef5
This commit is contained in:
committed by
George Joseph
parent
c40050d350
commit
479723f3cc
@@ -26,6 +26,9 @@
|
||||
#ifndef _ASTERISK_DNS_INTERNAL_H
|
||||
#define _ASTERISK_DNS_INTERNAL_H
|
||||
|
||||
/*! \brief For AST_LIST */
|
||||
#include "asterisk/linkedlists.h"
|
||||
|
||||
/*! \brief For AST_VECTOR */
|
||||
#include "asterisk/vector.h"
|
||||
|
||||
@@ -57,6 +60,16 @@ struct ast_dns_record {
|
||||
char data[0];
|
||||
};
|
||||
|
||||
/*! \brief A TXT record */
|
||||
struct ast_dns_txt_record {
|
||||
/*! \brief Generic DNS record information */
|
||||
struct ast_dns_record generic;
|
||||
/*! \brief The number of character strings in the TXT record */
|
||||
size_t count;
|
||||
/*! \brief The raw DNS record */
|
||||
char data[0];
|
||||
};
|
||||
|
||||
/*! \brief An SRV record */
|
||||
struct ast_dns_srv_record {
|
||||
/*! \brief Generic DNS record information */
|
||||
@@ -199,6 +212,19 @@ struct ast_sched_context;
|
||||
*/
|
||||
struct ast_sched_context *ast_dns_get_sched(void);
|
||||
|
||||
/*!
|
||||
* \brief Allocate and parse a DNS TXT record
|
||||
* \since 16.10.0, 17.4.0
|
||||
*
|
||||
* \param query The DNS query
|
||||
* \param data This specific TXT record
|
||||
* \param size The size of the TXT record
|
||||
*
|
||||
* \retval non-NULL success
|
||||
* \retval NULL failure
|
||||
*/
|
||||
struct ast_dns_record *dns_txt_alloc(struct ast_dns_query *query, const char *data, const size_t size);
|
||||
|
||||
/*!
|
||||
* \brief Allocate and parse a DNS NAPTR record
|
||||
*
|
||||
|
||||
64
include/asterisk/dns_txt.h
Normal file
64
include/asterisk/dns_txt.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 2020, Sean Bright
|
||||
*
|
||||
* Sean Bright <sean.bright@gmail.com>
|
||||
*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2. See the LICENSE file
|
||||
* at the top of the source tree.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief DNS TXT Record Parsing API
|
||||
* \author Sean Bright <sean.bright@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef ASTERISK_DNS_TXT_H
|
||||
#define ASTERISK_DNS_TXT_H
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Get the number of character strings in a TXT record
|
||||
* \since 16.10.0, 17.4.0
|
||||
*
|
||||
* \param record The DNS record
|
||||
*
|
||||
* \return the number of character strings in this TXT record
|
||||
*/
|
||||
size_t ast_dns_txt_get_count(const struct ast_dns_record *record);
|
||||
|
||||
/*!
|
||||
* \brief Get the character strings from this TXT record
|
||||
* \since 16.10.0, 17.4.0
|
||||
*
|
||||
* \param record The DNS record
|
||||
*
|
||||
* \retval NULL Unable to allocate memory
|
||||
* \return Vector of strings. Free with ast_dns_txt_free_strings
|
||||
*/
|
||||
struct ast_vector_string *ast_dns_txt_get_strings(const struct ast_dns_record *record);
|
||||
|
||||
/*!
|
||||
* \brief Free strings returned by ast_dns_txt_get_strings
|
||||
* \since 16.10.0, 17.4.0
|
||||
*
|
||||
* \param strings The vector to free
|
||||
*/
|
||||
void ast_dns_txt_free_strings(struct ast_vector_string *strings);
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ASTERISK_DNS_TXT_H */
|
||||
Reference in New Issue
Block a user