11cb0ef41Sopenharmony_ci/* MIT License
21cb0ef41Sopenharmony_ci *
31cb0ef41Sopenharmony_ci * Copyright (c) 2009 Daniel Stenberg
41cb0ef41Sopenharmony_ci *
51cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
61cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal
71cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights
81cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is
101cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions:
111cb0ef41Sopenharmony_ci *
121cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next
131cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
141cb0ef41Sopenharmony_ci * Software.
151cb0ef41Sopenharmony_ci *
161cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
171cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
201cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
211cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
221cb0ef41Sopenharmony_ci * SOFTWARE.
231cb0ef41Sopenharmony_ci *
241cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT
251cb0ef41Sopenharmony_ci */
261cb0ef41Sopenharmony_ci#ifndef __ARES_DATA_H
271cb0ef41Sopenharmony_ci#define __ARES_DATA_H
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_citypedef enum {
301cb0ef41Sopenharmony_ci  ARES_DATATYPE_UNKNOWN = 1, /* unknown data type     - introduced in 1.7.0 */
311cb0ef41Sopenharmony_ci  ARES_DATATYPE_SRV_REPLY,   /* struct ares_srv_reply - introduced in 1.7.0 */
321cb0ef41Sopenharmony_ci  ARES_DATATYPE_TXT_REPLY,   /* struct ares_txt_reply - introduced in 1.7.0 */
331cb0ef41Sopenharmony_ci  ARES_DATATYPE_TXT_EXT,     /* struct ares_txt_ext   - introduced in 1.11.0 */
341cb0ef41Sopenharmony_ci  ARES_DATATYPE_ADDR_NODE,   /* struct ares_addr_node - introduced in 1.7.1 */
351cb0ef41Sopenharmony_ci  ARES_DATATYPE_MX_REPLY,    /* struct ares_mx_reply   - introduced in 1.7.2 */
361cb0ef41Sopenharmony_ci  ARES_DATATYPE_NAPTR_REPLY, /* struct ares_naptr_reply - introduced in 1.7.6 */
371cb0ef41Sopenharmony_ci  ARES_DATATYPE_SOA_REPLY,   /* struct ares_soa_reply - introduced in 1.9.0 */
381cb0ef41Sopenharmony_ci  ARES_DATATYPE_URI_REPLY,   /* struct ares_uri_reply */
391cb0ef41Sopenharmony_ci#if 0
401cb0ef41Sopenharmony_ci  ARES_DATATYPE_ADDR6TTL,     /* struct ares_addrttl   */
411cb0ef41Sopenharmony_ci  ARES_DATATYPE_ADDRTTL,      /* struct ares_addr6ttl  */
421cb0ef41Sopenharmony_ci  ARES_DATATYPE_HOSTENT,      /* struct hostent        */
431cb0ef41Sopenharmony_ci  ARES_DATATYPE_OPTIONS,      /* struct ares_options   */
441cb0ef41Sopenharmony_ci#endif
451cb0ef41Sopenharmony_ci  ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced
461cb0ef41Sopenharmony_ci                                   in 1.11.0 */
471cb0ef41Sopenharmony_ci  ARES_DATATYPE_CAA_REPLY, /* struct ares_caa_reply   - introduced in 1.17 */
481cb0ef41Sopenharmony_ci  ARES_DATATYPE_LAST       /* not used              - introduced in 1.7.0 */
491cb0ef41Sopenharmony_ci} ares_datatype;
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci#define ARES_DATATYPE_MARK 0xbead
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci/*
541cb0ef41Sopenharmony_ci * ares_data struct definition is internal to c-ares and shall not
551cb0ef41Sopenharmony_ci * be exposed by the public API in order to allow future changes
561cb0ef41Sopenharmony_ci * and extensions to it without breaking ABI.  This will be used
571cb0ef41Sopenharmony_ci * internally by c-ares as the container of multiple types of data
581cb0ef41Sopenharmony_ci * dynamically allocated for which a reference will be returned
591cb0ef41Sopenharmony_ci * to the calling application.
601cb0ef41Sopenharmony_ci *
611cb0ef41Sopenharmony_ci * c-ares API functions returning a pointer to c-ares internally
621cb0ef41Sopenharmony_ci * allocated data will actually be returning an interior pointer
631cb0ef41Sopenharmony_ci * into this ares_data struct.
641cb0ef41Sopenharmony_ci *
651cb0ef41Sopenharmony_ci * All this is 'invisible' to the calling application, the only
661cb0ef41Sopenharmony_ci * requirement is that this kind of data must be free'ed by the
671cb0ef41Sopenharmony_ci * calling application using ares_free_data() with the pointer
681cb0ef41Sopenharmony_ci * it has received from a previous c-ares function call.
691cb0ef41Sopenharmony_ci */
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_cistruct ares_data {
721cb0ef41Sopenharmony_ci  ares_datatype type; /* Actual data type identifier. */
731cb0ef41Sopenharmony_ci  unsigned int  mark; /* Private ares_data signature. */
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci  union {
761cb0ef41Sopenharmony_ci    struct ares_txt_reply      txt_reply;
771cb0ef41Sopenharmony_ci    struct ares_txt_ext        txt_ext;
781cb0ef41Sopenharmony_ci    struct ares_srv_reply      srv_reply;
791cb0ef41Sopenharmony_ci    struct ares_addr_node      addr_node;
801cb0ef41Sopenharmony_ci    struct ares_addr_port_node addr_port_node;
811cb0ef41Sopenharmony_ci    struct ares_mx_reply       mx_reply;
821cb0ef41Sopenharmony_ci    struct ares_naptr_reply    naptr_reply;
831cb0ef41Sopenharmony_ci    struct ares_soa_reply      soa_reply;
841cb0ef41Sopenharmony_ci    struct ares_caa_reply      caa_reply;
851cb0ef41Sopenharmony_ci    struct ares_uri_reply      uri_reply;
861cb0ef41Sopenharmony_ci  } data;
871cb0ef41Sopenharmony_ci};
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_civoid *ares_malloc_data(ares_datatype type);
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci#endif /* __ARES_DATA_H */
93