ttl.c revision cd750f6e7449678173e8cfe080ae0bf3dcb424cf
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews/*
6fb9b25791778f69002eb72be6235e20d98ec452Tinderbox User * Copyright (C) 2004, 2005, 2007, 2011-2014 Internet Systems Consortium, Inc. ("ISC")
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * Copyright (C) 1999-2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * copyright notice and this permission notice appear in all copies.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews *
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews/* $Id$ */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews/*! \file */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <config.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <ctype.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <errno.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <stdio.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <stdlib.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/buffer.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/parseint.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/print.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/region.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/string.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <isc/util.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <dns/result.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#include <dns/ttl.h>
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews#define RETERR(x) do { \
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt isc_result_t _r = (x); \
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (_r != ISC_R_SUCCESS) \
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (_r); \
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews } while (0)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsstatic isc_result_t bind_ttl(isc_textregion_t *source, isc_uint32_t *ttl);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews/*
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * Helper for dns_ttl_totext().
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsstatic isc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsttlfmt(unsigned int t, const char *s, isc_boolean_t verbose,
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_boolean_t space, isc_buffer_t *target)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews{
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews char tmp[60];
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews unsigned int len;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_region_t region;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (verbose)
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater len = snprintf(tmp, sizeof(tmp), "%s%u %s%s",
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews space ? " " : "",
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews t, s,
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews t == 1 ? "" : "s");
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews else
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews len = snprintf(tmp, sizeof(tmp), "%u%c", t, s[0]);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews INSIST(len + 1 <= sizeof(tmp));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_buffer_availableregion(target, &region);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (len > region.length)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (ISC_R_NOSPACE);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews memmove(region.base, tmp, len);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_buffer_add(target, len);
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (ISC_R_SUCCESS);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews/*
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * Derived from bind8 ns_format_ttl().
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsisc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsdns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose, isc_buffer_t *target) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (dns_ttl_totext2(src, verbose, ISC_TRUE, target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsisc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsdns_ttl_totext2(isc_uint32_t src, isc_boolean_t verbose,
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_boolean_t upcase, isc_buffer_t *target)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews{
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews unsigned secs, mins, hours, days, weeks, x;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews secs = src % 60; src /= 60;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews mins = src % 60; src /= 60;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews hours = src % 24; src /= 24;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews days = src % 7; src /= 7;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews weeks = src; src = 0;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews POST(src);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x = 0;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (weeks != 0) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews RETERR(ttlfmt(weeks, "week", verbose, ISC_TF(x > 0), target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (days != 0) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews RETERR(ttlfmt(days, "day", verbose, ISC_TF(x > 0), target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (hours != 0) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews RETERR(ttlfmt(hours, "hour", verbose, ISC_TF(x > 0), target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (mins != 0) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews RETERR(ttlfmt(mins, "minute", verbose, ISC_TF(x > 0), target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (secs != 0 ||
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews (weeks == 0 && days == 0 && hours == 0 && mins == 0)) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews RETERR(ttlfmt(secs, "second", verbose, ISC_TF(x > 0), target));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews x++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews INSIST (x > 0);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews /*
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * If only a single unit letter is printed, print it
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * in upper case. (Why? Because BIND 8 does that.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * Presumably it has a reason.)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (x == 1 && upcase && !verbose) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_region_t region;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews /*
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * The unit letter is the last character in the
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * used region of the buffer.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews *
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * toupper() does not need its argument to be masked of cast
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * here because region.base is type unsigned char *.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_buffer_usedregion(target, &region);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews region.base[region.length - 1] =
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews toupper(region.base[region.length - 1]);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (ISC_R_SUCCESS);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsisc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsdns_counter_fromtext(isc_textregion_t *source, isc_uint32_t *ttl) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (bind_ttl(source, ttl));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
931814de4ad11f20b85c3b50399e2e7dda2e7d47Francis Dupont
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsisc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsdns_ttl_fromtext(isc_textregion_t *source, isc_uint32_t *ttl) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_result_t result;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews result = bind_ttl(source, ttl);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (result != ISC_R_SUCCESS && result != ISC_R_RANGE)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews result = DNS_R_BADTTL;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (result);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsstatic isc_result_t
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrewsbind_ttl(isc_textregion_t *source, isc_uint32_t *ttl) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_uint64_t tmp = 0ULL;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_uint32_t n;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews char *s;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews char buf[64];
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater char nbuf[64]; /* Number buffer */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews /*
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * Copy the buffer as it may not be NULL terminated.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews * No legal counter / ttl is longer that 63 characters.
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (source->length > sizeof(buf) - 1)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (DNS_R_SYNTAX);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews strncpy(buf, source->base, source->length);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews buf[source->length] = '\0';
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater s = buf;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews do {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews isc_result_t result;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews char *np = nbuf;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews while (*s != '\0' && isdigit((unsigned char)*s))
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews *np++ = *s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews *np++ = '\0';
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews INSIST(np - nbuf <= (int)sizeof(nbuf));
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews result = isc_parse_uint32(&n, nbuf, 10);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (result != ISC_R_SUCCESS)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (DNS_R_SYNTAX);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews switch (*s) {
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'w':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'W':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp += (isc_uint64_t) n * 7 * 24 * 3600;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'd':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'D':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp += (isc_uint64_t) n * 24 * 3600;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'h':
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater case 'H':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp += (isc_uint64_t) n * 3600;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'm':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'M':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp += (isc_uint64_t) n * 60;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 's':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case 'S':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp += (isc_uint64_t) n;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews s++;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews case '\0':
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews /* Plain number? */
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (tmp != 0ULL)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (DNS_R_SYNTAX);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews tmp = n;
8a07de2f032b0137d89ae8af14faa1a915aaf9faAutomatic Updater break;
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews default:
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (DNS_R_SYNTAX);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews }
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews } while (*s != '\0');
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews if (tmp > 0xffffffffULL)
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (ISC_R_RANGE);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews *ttl = (isc_uint32_t)(tmp & 0xffffffffUL);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews return (ISC_R_SUCCESS);
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews}
d1bcaec0d6c3a2f6afe004c1a087314015cb77c0Mark Andrews