This file is indexed.

/usr/include/ldns/rdata.h is in libldns-dev 1.6.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/*
 * rdata.h
 *
 * rdata definitions
 *
 * a Net::DNS like library for C
 *
 * (c) NLnet Labs, 2005-2006
 *
 * See the file LICENSE for the license
 */


/**
 * \file
 *
 * Defines ldns_rdf and functions to manipulate those.
 */


#ifndef LDNS_RDATA_H
#define LDNS_RDATA_H

#include <ldns/common.h>
#include <ldns/error.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LDNS_MAX_RDFLEN	8192

#define LDNS_RDF_SIZE_BYTE              1
#define LDNS_RDF_SIZE_WORD              2
#define LDNS_RDF_SIZE_DOUBLEWORD        4
#define LDNS_RDF_SIZE_6BYTES            6
#define LDNS_RDF_SIZE_16BYTES           16

#define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01

/**
 * The different types of RDATA fields.
 */
enum ldns_enum_rdf_type
{
	/** none */
	LDNS_RDF_TYPE_NONE,
	/** domain name */
	LDNS_RDF_TYPE_DNAME,
	/** 8 bits */
	LDNS_RDF_TYPE_INT8,
	/** 16 bits */
	LDNS_RDF_TYPE_INT16,
	/** 32 bits */
	LDNS_RDF_TYPE_INT32,
	/** A record */
	LDNS_RDF_TYPE_A,
	/** AAAA record */
	LDNS_RDF_TYPE_AAAA,
	/** txt string */
	LDNS_RDF_TYPE_STR,
	/** apl data */
	LDNS_RDF_TYPE_APL,
	/** b32 string */
	LDNS_RDF_TYPE_B32_EXT,
	/** b64 string */
	LDNS_RDF_TYPE_B64,
	/** hex string */
	LDNS_RDF_TYPE_HEX,
	/** nsec type codes */
	LDNS_RDF_TYPE_NSEC,
	/** a RR type */
	LDNS_RDF_TYPE_TYPE,
	/** a class */
	LDNS_RDF_TYPE_CLASS,
	/** certificate algorithm */
	LDNS_RDF_TYPE_CERT_ALG,
	/** a key algorithm */
	LDNS_RDF_TYPE_ALG,
	/** unknown types */
	LDNS_RDF_TYPE_UNKNOWN,
	/** time (32 bits) */
	LDNS_RDF_TYPE_TIME,
	/** period */
	LDNS_RDF_TYPE_PERIOD,
	/** tsig time 48 bits */
	LDNS_RDF_TYPE_TSIGTIME,
	LDNS_RDF_TYPE_TSIG,
	/** variable length any type rdata where the length
	    is specified by the first 2 bytes */
	LDNS_RDF_TYPE_INT16_DATA,
	/** protocol and port bitmaps */
	LDNS_RDF_TYPE_SERVICE,
	/** location data */
	LDNS_RDF_TYPE_LOC,
	/** well known services */
	LDNS_RDF_TYPE_WKS,
	/** NSAP */
	LDNS_RDF_TYPE_NSAP,
	/** ATMA */
	LDNS_RDF_TYPE_ATMA,
	/** IPSECKEY */
	LDNS_RDF_TYPE_IPSECKEY,
	/** nsec3 hash salt */
	LDNS_RDF_TYPE_NSEC3_SALT,
	/** nsec3 base32 string (with length byte on wire */
	LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
};
typedef enum ldns_enum_rdf_type ldns_rdf_type;

/**
 * algorithms used in CERT rrs
 */
enum ldns_enum_cert_algorithm
{
        LDNS_CERT_PKIX		= 1,
        LDNS_CERT_SPKI		= 2,
        LDNS_CERT_PGP		= 3,
        LDNS_CERT_IPKIX         = 4,
        LDNS_CERT_ISPKI         = 5,
        LDNS_CERT_IPGP          = 6,
        LDNS_CERT_ACPKIX        = 7,
        LDNS_CERT_IACPKIX       = 8,
        LDNS_CERT_URI		= 253,
        LDNS_CERT_OID		= 254
};
typedef enum ldns_enum_cert_algorithm ldns_cert_algorithm;



/**
 * Resource record data field.
 *
 * The data is a network ordered array of bytes, which size is specified by
 * the (16-bit) size field. To correctly parse it, use the type
 * specified in the (16-bit) type field with a value from \ref ldns_rdf_type.
 */
struct ldns_struct_rdf
{
	/** The size of the data (in octets) */
	size_t _size;
	/** The type of the data */
	ldns_rdf_type _type;
	/** Pointer to the data (raw octets) */
	void  *_data;
};
typedef struct ldns_struct_rdf ldns_rdf;

/* prototypes */

/* write access functions */

/**
 * sets the size of the rdf.
 * \param[in] *rd the rdf to operate on
 * \param[in] size the new size
 * \return void
 */
void ldns_rdf_set_size(ldns_rdf *rd, size_t size);

/**
 * sets the size of the rdf.
 * \param[in] *rd the rdf to operate on
 * \param[in] type the new type
 * \return void
 */
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type);

/**
 * sets the size of the rdf.
 * \param[in] *rd the rdf to operate on
 * \param[in] *data pointer to the new data
 * \return void
 */
void ldns_rdf_set_data(ldns_rdf *rd, void *data);

/* read access */

/**
 * returns the size of the rdf.
 * \param[in] *rd the rdf to read from
 * \return uint16_t with the size
 */
size_t ldns_rdf_size(const ldns_rdf *rd);

/**
 * returns the type of the rdf. We need to insert _get_
 * here to prevent conflict the the rdf_type TYPE.
 * \param[in] *rd the rdf to read from
 * \return ldns_rdf_type with the type
 */
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd);

/**
 * returns the data of the rdf.
 * \param[in] *rd the rdf to read from
 * \return uint8_t* pointer to the rdf's data
 */
uint8_t *ldns_rdf_data(const ldns_rdf *rd);

/* creator functions */

/**
 * allocates a new rdf structure and fills it.
 * This function DOES NOT copy the contents from
 * the buffer, unlinke ldns_rdf_new_frm_data()
 * \param[in] type type of the rdf
 * \param[in] size size of the buffer
 * \param[in] data pointer to the buffer to be copied
 * \return the new rdf structure or NULL on failure
 */
ldns_rdf *ldns_rdf_new(ldns_rdf_type type, size_t size, void *data);

/**
 * allocates a new rdf structure and fills it.
 * This function _does_ copy the contents from
 * the buffer, unlinke ldns_rdf_new()
 * \param[in] type type of the rdf
 * \param[in] size size of the buffer
 * \param[in] data pointer to the buffer to be copied
 * \return the new rdf structure or NULL on failure
 */
ldns_rdf *ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data);

/**
 * creates a new rdf from a string.
 * \param[in] type   type to use
 * \param[in] str string to use
 * \return ldns_rdf* or NULL in case of an error
 */
ldns_rdf *ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str);

/**
 * creates a new rdf from a file containing a string.
 * \param[out] r the new rdf
 * \param[in] type   type to use
 * \param[in] fp the file pointer  to use
 * \return LDNS_STATUS_OK or the error
 */
ldns_status ldns_rdf_new_frm_fp(ldns_rdf **r, ldns_rdf_type type, FILE *fp);

/**
 * creates a new rdf from a file containing a string.
 * \param[out] r the new rdf
 * \param[in] type   type to use
 * \param[in] fp the file pointer  to use
 * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
 * \return LDNS_STATUS_OK or the error
 */
ldns_status ldns_rdf_new_frm_fp_l(ldns_rdf **r, ldns_rdf_type type, FILE *fp, int *line_nr);

/* destroy functions */

/**
 * frees a rdf structure, leaving the
 * data pointer intact.
 * \param[in] rd the pointer to be freed
 * \return void
 */
void ldns_rdf_free(ldns_rdf *rd);

/**
 * frees a rdf structure _and_ frees the
 * data. rdf should be created with _new_frm_data
 * \param[in] rd the rdf structure to be freed
 * \return void
 */
void ldns_rdf_deep_free(ldns_rdf *rd);

/* conversion functions */

/**
 * returns the rdf containing the native uint8_t repr.
 * \param[in] type the ldns_rdf type to use
 * \param[in] value the uint8_t to use
 * \return ldns_rdf* with the converted value
 */
ldns_rdf *ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);

/**
 * returns the rdf containing the native uint16_t representation.
 * \param[in] type the ldns_rdf type to use
 * \param[in] value the uint16_t to use
 * \return ldns_rdf* with the converted value
 */
ldns_rdf *ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);

/**
 * returns an rdf that contains the given int32 value.
 *
 * Because multiple rdf types can contain an int32, the
 * type must be specified
 * \param[in] type the ldns_rdf type to use
 * \param[in] value the uint32_t to use
 * \return ldns_rdf* with the converted value
 */
ldns_rdf *ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);

/**
 * returns an int16_data rdf that contains the data in the
 * given array, preceded by an int16 specifying the length.
 *
 * The memory is copied, and an LDNS_RDF_TYPE_INT16DATA is returned
 * \param[in] size the size of the data
 * \param[in] *data pointer to the actual data
 * \return ldns_rd* the rdf with the data
 */
ldns_rdf *ldns_native2rdf_int16_data(size_t size, uint8_t *data);

/**
 * reverses an rdf, only actually useful for AAAA and A records.
 * The returned rdf has the type LDNS_RDF_TYPE_DNAME!
 * \param[in] *rd rdf to be reversed
 * \return the reversed rdf (a newly created rdf)
 */
ldns_rdf *ldns_rdf_address_reverse(ldns_rdf *rd);

/**
 * returns the native uint8_t representation from the rdf.
 * \param[in] rd the ldns_rdf to operate on
 * \return uint8_t the value extracted
 */
uint8_t 	ldns_rdf2native_int8(const ldns_rdf *rd);

/**
 * returns the native uint16_t representation from the rdf.
 * \param[in] rd the ldns_rdf to operate on
 * \return uint16_t the value extracted
 */
uint16_t	ldns_rdf2native_int16(const ldns_rdf *rd);

/**
 * returns the native uint32_t representation from the rdf.
 * \param[in] rd the ldns_rdf to operate on
 * \return uint32_t the value extracted
 */
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd);

/**
 * returns the native time_t representation from the rdf.
 * \param[in] rd the ldns_rdf to operate on
 * \return time_t the value extracted (32 bits currently)
 */
time_t ldns_rdf2native_time_t(const ldns_rdf *rd);

/**
 * converts a ttl value (like 5d2h) to a long.
 * \param[in] nptr the start of the string
 * \param[out] endptr points to the last char in case of error
 * \return the convert duration value
 */
uint32_t ldns_str2period(const char *nptr, const char **endptr);

/**
 * removes \\DDD, \\[space] and other escapes from the input.
 * See RFC 1035, section 5.1.
 * \param[in] word what to check
 * \param[in] length the string
 * \return ldns_status mesg
 */
ldns_status ldns_octet(char *word, size_t *length);

/**
 * clones a rdf structure. The data is copied.
 * \param[in] rd rdf to be copied
 * \return a new rdf structure
 */
ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);

/**
 * compares two rdf's on their wire formats.
 * (To order dnames according to rfc4034, use ldns_dname_compare)
 * \param[in] rd1 the first one
 * \param[in] rd2 the second one
 * \return 0 if equal
 * \return -1 if rd1 comes before rd2
 * \return +1 if rd2 comes before rd1
 */
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2);

#ifdef __cplusplus
}
#endif

#endif	/* LDNS_RDATA_H */