soa.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Copyright (C) 2000, 2001, 2004, 2005, 2007, 2009, 2016 Internet Systems Consortium, Inc. ("ISC")
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * This Source Code Form is subject to the terms of the Mozilla Public
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * License, v. 2.0. If a copy of the MPL was not distributed with this
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington/* $Id: soa.c,v 1.12 2009/09/10 02:18:40 each Exp $ */
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtondecode_uint32(unsigned char *p) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return ((p[0] << 24) +
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (p[3] << 0));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonstatic inline void
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonencode_uint32(isc_uint32_t val, unsigned char *p) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Locate the field within the SOA RDATA based
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * on its position relative to the end of the data.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * This is a bit of a kludge, but the alternative approach of
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * using dns_rdata_tostruct() and dns_rdata_fromstruct() would
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington * involve a lot of unnecessary work (like building domain
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington * names and allocating temporary memory) when all we really
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * want to do is to get 32 bits of fixed-sized data.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return (decode_uint32(rdata->data + rdata->length - 20 + offset));
3f6dc1703f76a24b34ed3bc839447291c33ca837Brian Wellingtondns_soa_buildrdata(dns_name_t *origin, dns_name_t *contact,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_uint32_t minimum, unsigned char *buffer,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_buffer_init(&rdatabuf, buffer, DNS_SOA_BUFFERSIZE);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington return (dns_rdata_fromstruct(rdata, rdclass, dns_rdatatype_soa,
d598338952797df77417e69fcb8782b73651f9a9Brian Wellingtonsoa_set(dns_rdata_t *rdata, isc_uint32_t val, int offset) {
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington encode_uint32(val, rdata->data + rdata->length - 20 + offset);
d598338952797df77417e69fcb8782b73651f9a9Brian Wellingtondns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata) {
d598338952797df77417e69fcb8782b73651f9a9Brian Wellingtondns_soa_setrefresh(isc_uint32_t val, dns_rdata_t *rdata) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtondns_soa_setretry(isc_uint32_t val, dns_rdata_t *rdata) {
0a595c94a4137c3d56d529b86f5b8661513b16c3Brian Wellingtondns_soa_setexpire(isc_uint32_t val, dns_rdata_t *rdata) {