1126274Sdes/* OPENBSD BASED ON : include/netdb.h */
2126274Sdes
3124208Sdes/* $OpenBSD: getrrsetbyname.c,v 1.4 2001/08/16 18:16:43 ho Exp $ */
4124208Sdes
5124208Sdes/*
6124208Sdes * Copyright (c) 2001 Jakob Schlyter. All rights reserved.
7124208Sdes *
8124208Sdes * Redistribution and use in source and binary forms, with or without
9124208Sdes * modification, are permitted provided that the following conditions
10124208Sdes * are met:
11124208Sdes *
12124208Sdes * 1. Redistributions of source code must retain the above copyright
13124208Sdes *    notice, this list of conditions and the following disclaimer.
14124208Sdes *
15124208Sdes * 2. Redistributions in binary form must reproduce the above copyright
16124208Sdes *    notice, this list of conditions and the following disclaimer in the
17124208Sdes *    documentation and/or other materials provided with the distribution.
18124208Sdes *
19124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20124208Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21124208Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22124208Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23124208Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24124208Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25124208Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26124208Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27124208Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28124208Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29124208Sdes */
30124208Sdes
31124208Sdes/*
32124208Sdes * Portions Copyright (c) 1999-2001 Internet Software Consortium.
33124208Sdes *
34124208Sdes * Permission to use, copy, modify, and distribute this software for any
35124208Sdes * purpose with or without fee is hereby granted, provided that the above
36124208Sdes * copyright notice and this permission notice appear in all copies.
37124208Sdes *
38124208Sdes * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
39124208Sdes * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
40124208Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
41124208Sdes * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
42124208Sdes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
43124208Sdes * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
44124208Sdes * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
45124208Sdes * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
46124208Sdes */
47124208Sdes
48124208Sdes#ifndef _GETRRSETBYNAME_H
49124208Sdes#define _GETRRSETBYNAME_H
50124208Sdes
51124208Sdes#include "includes.h"
52124208Sdes
53126274Sdes#ifndef HAVE_GETRRSETBYNAME
54124208Sdes
55124208Sdes#include <sys/types.h>
56124208Sdes#include <netinet/in.h>
57124208Sdes#include <arpa/nameser.h>
58124208Sdes#include <netdb.h>
59124208Sdes#include <resolv.h>
60124208Sdes
61126274Sdes#ifndef HFIXEDSZ
62126274Sdes#define HFIXEDSZ 12
63126274Sdes#endif
64126274Sdes
65181111Sdes#ifndef T_RRSIG
66181111Sdes#define T_RRSIG 46
67126274Sdes#endif
68126274Sdes
69124208Sdes/*
70124208Sdes * Flags for getrrsetbyname()
71124208Sdes */
72124208Sdes#ifndef RRSET_VALIDATED
73124208Sdes# define RRSET_VALIDATED	1
74124208Sdes#endif
75124208Sdes
76124208Sdes/*
77124208Sdes * Return codes for getrrsetbyname()
78124208Sdes */
79124208Sdes#ifndef ERRSET_SUCCESS
80124208Sdes# define ERRSET_SUCCESS		0
81124208Sdes# define ERRSET_NOMEMORY	1
82124208Sdes# define ERRSET_FAIL		2
83124208Sdes# define ERRSET_INVAL		3
84124208Sdes# define ERRSET_NONAME		4
85124208Sdes# define ERRSET_NODATA		5
86124208Sdes#endif
87124208Sdes
88124208Sdesstruct rdatainfo {
89124208Sdes	unsigned int		rdi_length;	/* length of data */
90124208Sdes	unsigned char		*rdi_data;	/* record data */
91124208Sdes};
92124208Sdes
93124208Sdesstruct rrsetinfo {
94124208Sdes	unsigned int		rri_flags;	/* RRSET_VALIDATED ... */
95124208Sdes	unsigned int		rri_rdclass;	/* class number */
96124208Sdes	unsigned int		rri_rdtype;	/* RR type number */
97124208Sdes	unsigned int		rri_ttl;	/* time to live */
98124208Sdes	unsigned int		rri_nrdatas;	/* size of rdatas array */
99124208Sdes	unsigned int		rri_nsigs;	/* size of sigs array */
100124208Sdes	char			*rri_name;	/* canonical name */
101124208Sdes	struct rdatainfo	*rri_rdatas;	/* individual records */
102124208Sdes	struct rdatainfo	*rri_sigs;	/* individual signatures */
103124208Sdes};
104124208Sdes
105124208Sdesint		getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **);
106124208Sdesvoid		freerrset(struct rrsetinfo *);
107124208Sdes
108126274Sdes#endif /* !defined(HAVE_GETRRSETBYNAME) */
109124208Sdes
110124208Sdes#endif /* _GETRRSETBYNAME_H */
111