opt.h 2.6 KB
Newer Older
1
/*
Brian Wellington's avatar
Brian Wellington committed
2
 * Copyright (C) 2000, 2001  Internet Software Consortium.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

Brian Wellington's avatar
Brian Wellington committed
18
/* $Id: opt.h,v 1.8 2001/03/12 22:27:15 bwelling Exp $ */
19
20

/* DNS_OPT_NEWCODES_KEEP */
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

#ifndef DNS_OPT_H
#define DNS_OPT_H 1

#include <isc/lang.h>
#include <isc/result.h>
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/types.h>

#include <dns/rdataset.h>
#include <dns/message.h>

/*
 * XXX WARNING XXX  These codes have not yet been assigned by IANA.
 * These are here as placekeepers ONLY.
 * Hide these definitions and anything that uses them behind a #define 
 * which happens only in internal debugging code.
 * This #ifdef will go away once these are defined by IANA.
 */
#ifdef DNS_OPT_NEWCODES
#define DNS_OPTCODE_ZONE 0xfff0
#define DNS_OPTCODE_VIEW 0xfff1
#endif /* DNS_OPT_NEWCODES */

Brian Wellington's avatar
Brian Wellington committed
46
#define DNS_OPT_FLAGS(opt) ((isc_uint16_t)((opt)->ttl & 0xFFFF))
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
/*
 * OPT records contain a series of attributes which contain different types.
 * These structures are used for holding the individual attribute
 * records.
 */
typedef struct dns_optattr {
	isc_uint16_t                    code;
	isc_region_t                    value;
} dns_optattr_t;

typedef struct dns_optlist {
	unsigned int                    size;
        unsigned int                    used;
	unsigned int                    next;
        dns_optattr_t                  *attrs;
} dns_optlist_t;

isc_result_t
dns_opt_decode(dns_optlist_t *optlist, dns_rdataset_t *optset,
	       isc_uint16_t code);

isc_result_t
dns_opt_decodeall(dns_optlist_t *optlist, dns_rdataset_t *optset);

isc_result_t
dns_opt_add(dns_rdata_t *rdata, dns_optlist_t *optlist,
	    isc_buffer_t *target);

isc_result_t
dns_opt_attrtotext(dns_optattr_t *attr, isc_buffer_t *target,
		   dns_messagetextflag_t flags);

isc_result_t
dns_opt_totext(dns_rdataset_t *opt, isc_buffer_t *target,
	       dns_messagetextflag_t flags);

ISC_LANG_ENDDECLS

#endif /* DNS_OPT_H */