zonecut.h 2.21 KB
Newer Older
Marek Vavruša's avatar
Marek Vavruša committed
1
/*  Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
2

Marek Vavruša's avatar
Marek Vavruša committed
3 4 5 6
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
7

Marek Vavruša's avatar
Marek Vavruša committed
8 9 10 11
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
12

Marek Vavruša's avatar
Marek Vavruša committed
13 14 15
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
16

Marek Vavruša's avatar
Marek Vavruša committed
17 18 19 20
/** \addtogroup rplan
 * @{ 
 */

21 22
#pragma once

Marek Vavruša's avatar
Marek Vavruša committed
23 24
#include <libknot/dname.h>
#include <libknot/rrset.h>
25
#include <libknot/internal/sockaddr.h>
Marek Vavruša's avatar
Marek Vavruša committed
26
#include <libknot/internal/namedb/namedb.h>
27

Marek Vavruša's avatar
Marek Vavruša committed
28
struct kr_rplan;
29

Marek Vavruša's avatar
Marek Vavruša committed
30 31
/**
 * Current zone cut representation.
Marek Vavruša's avatar
Marek Vavruša committed
32 33
*/
struct kr_zonecut {
Marek Vavruša's avatar
Marek Vavruša committed
34 35 36
	knot_dname_t name[KNOT_DNAME_MAXLEN]; /**< Current zone cut */
	knot_dname_t ns[KNOT_DNAME_MAXLEN];   /**< Authoritative NS */
	struct sockaddr_storage addr;         /**< Authoritative NS address. */
37 38
};

Marek Vavruša's avatar
Marek Vavruša committed
39 40 41 42
/**
 * Initialize zone cut with SBELT.
 * @param cut zone cut to be set
 * @return KNOT_E*
43 44 45
 */
int kr_init_zone_cut(struct kr_zonecut *cut);

Marek Vavruša's avatar
Marek Vavruša committed
46 47 48 49 50 51 52
/**
 * Set zone cut to given name and name server.
 * @note Name server address is blanked.
 * @param cut zone cut to be set
 * @param name zone cut name
 * @param ns   zone cut nameserver
 * @return KNOT_E*
53
 */
Marek Vavruša's avatar
Marek Vavruša committed
54 55
int kr_set_zone_cut(struct kr_zonecut *cut, const knot_dname_t *name, const knot_dname_t *ns);

Marek Vavruša's avatar
Marek Vavruša committed
56 57 58 59 60 61
/**
 * Convert A/AAAA RRs to address with DNS port.
 * @param cut zone cut to be set
 * @param rr resource record
 * @param i  index of the set address in the rr
 * @return KNOT_E*
62 63 64
 */
int kr_set_zone_cut_addr(struct kr_zonecut *cut, const knot_rrset_t *rr, uint16_t i);

Marek Vavruša's avatar
Marek Vavruša committed
65 66 67 68 69 70 71
/**
 * Find the closest enclosing zone cut/nameserver from the cache.
 * @param cut zone cut to be set
 * @param name zone cut name
 * @param txn cache transaction
 * @param timestamp transaction timestamp
 * @return KNOT_E*
Marek Vavruša's avatar
Marek Vavruša committed
72 73
 */
int kr_find_zone_cut(struct kr_zonecut *cut, const knot_dname_t *name, namedb_txn_t *txn, uint32_t timestamp);
74

Marek Vavruša's avatar
Marek Vavruša committed
75
/** @} */