0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2000, 2001, 2004, 2005, 2007, 2009, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
0e7cb68ea0c0bf27d1a02b02c501045faef27ae2Evan Hunt/* $Id: soa.c,v 1.12 2009/09/10 02:18:40 each Exp $ */
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson return ((p[0] << 24) +
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonstatic inline void
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonencode_uint32(isc_uint32_t val, unsigned char *p) {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson INSIST(rdata->type == dns_rdatatype_soa);
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * Locate the field within the SOA RDATA based
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * on its position relative to the end of the data.
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * This is a bit of a kludge, but the alternative approach of
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * using dns_rdata_tostruct() and dns_rdata_fromstruct() would
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * involve a lot of unnecessary work (like building domain
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * names and allocating temporary memory) when all we really
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * want to do is to get 32 bits of fixed-sized data.
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson return (decode_uint32(rdata->data + rdata->length - 20 + offset));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Huntdns_soa_buildrdata(dns_name_t *origin, dns_name_t *contact,
c6fb85f9500350e5ce58c9a24f5d264c8a8bd6f4Automatic Updater isc_uint32_t serial, isc_uint32_t refresh,
dbabab1f37f9f1713d2179ce4bb4600499a1a3b1Evan Hunt isc_buffer_init(&rdatabuf, buffer, DNS_SOA_BUFFERSIZE);
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt return (dns_rdata_fromstruct(rdata, rdclass, dns_rdatatype_soa,
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonsoa_set(dns_rdata_t *rdata, isc_uint32_t val, int offset) {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson INSIST(rdata->type == dns_rdatatype_soa);
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson encode_uint32(val, rdata->data + rdata->length - 20 + offset);
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssondns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata) {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssondns_soa_setrefresh(isc_uint32_t val, dns_rdata_t *rdata) {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssondns_soa_setretry(isc_uint32_t val, dns_rdata_t *rdata) {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssondns_soa_setexpire(isc_uint32_t val, dns_rdata_t *rdata) {