1 #ifndef __ARES_DATA_H
2 #define __ARES_DATA_H
3 
4 
5 /* Copyright (C) 2009-2013 by Daniel Stenberg
6  *
7  * Permission to use, copy, modify, and distribute this
8  * software and its documentation for any purpose and without
9  * fee is hereby granted, provided that the above copyright
10  * notice appear in all copies and that both that copyright
11  * notice and this permission notice appear in supporting
12  * documentation, and that the name of M.I.T. not be used in
13  * advertising or publicity pertaining to distribution of the
14  * software without specific, written prior permission.
15  * M.I.T. makes no representations about the suitability of
16  * this software for any purpose.  It is provided "as is"
17  * without express or implied warranty.
18  */
19 
20 typedef enum {
21   ARES_DATATYPE_UNKNOWN = 1,  /* unknown data type     - introduced in 1.7.0 */
22   ARES_DATATYPE_SRV_REPLY,    /* struct ares_srv_reply - introduced in 1.7.0 */
23   ARES_DATATYPE_TXT_REPLY,    /* struct ares_txt_reply - introduced in 1.7.0 */
24   ARES_DATATYPE_TXT_EXT,      /* struct ares_txt_ext   - introduced in 1.11.0 */
25   ARES_DATATYPE_ADDR_NODE,    /* struct ares_addr_node - introduced in 1.7.1 */
26   ARES_DATATYPE_MX_REPLY,    /* struct ares_mx_reply   - introduced in 1.7.2 */
27   ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */
28   ARES_DATATYPE_SOA_REPLY,    /* struct ares_soa_reply - introduced in 1.9.0 */
29   ARES_DATATYPE_URI_REPLY, 	/* struct ares_uri_reply */
30 #if 0
31   ARES_DATATYPE_ADDR6TTL,     /* struct ares_addrttl   */
32   ARES_DATATYPE_ADDRTTL,      /* struct ares_addr6ttl  */
33   ARES_DATATYPE_HOSTENT,      /* struct hostent        */
34   ARES_DATATYPE_OPTIONS,      /* struct ares_options   */
35 #endif
36   ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
37   ARES_DATATYPE_CAA_REPLY,    /* struct ares_caa_reply   - introduced in 1.17 */
38   ARES_DATATYPE_LAST          /* not used              - introduced in 1.7.0 */
39 } ares_datatype;
40 
41 #define ARES_DATATYPE_MARK 0xbead
42 
43 /*
44  * ares_data struct definition is internal to c-ares and shall not
45  * be exposed by the public API in order to allow future changes
46  * and extensions to it without breaking ABI.  This will be used
47  * internally by c-ares as the container of multiple types of data
48  * dynamically allocated for which a reference will be returned
49  * to the calling application.
50  *
51  * c-ares API functions returning a pointer to c-ares internally
52  * allocated data will actually be returning an interior pointer
53  * into this ares_data struct.
54  *
55  * All this is 'invisible' to the calling application, the only
56  * requirement is that this kind of data must be free'ed by the
57  * calling application using ares_free_data() with the pointer
58  * it has received from a previous c-ares function call.
59  */
60 
61 struct ares_data {
62   ares_datatype type;  /* Actual data type identifier. */
63   unsigned int  mark;  /* Private ares_data signature. */
64   union {
65     struct ares_txt_reply    txt_reply;
66     struct ares_txt_ext      txt_ext;
67     struct ares_srv_reply    srv_reply;
68     struct ares_addr_node    addr_node;
69     struct ares_addr_port_node  addr_port_node;
70     struct ares_mx_reply     mx_reply;
71     struct ares_naptr_reply  naptr_reply;
72     struct ares_soa_reply    soa_reply;
73     struct ares_caa_reply    caa_reply;
74     struct ares_uri_reply    uri_reply;
75   } data;
76 };
77 
78 void *ares_malloc_data(ares_datatype type);
79 
80 
81 #endif /* __ARES_DATA_H */
82