"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.17.5/lib/dns/ecs.c" (4 Sep 2020, 1095 Bytes) of package /linux/misc/dns/bind9/9.17.5/bind-9.17.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ecs.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 /*! \file */
   13 
   14 #include <string.h>
   15 
   16 #include <isc/netaddr.h>
   17 #include <isc/print.h>
   18 #include <isc/util.h>
   19 
   20 #include <dns/ecs.h>
   21 #include <dns/types.h>
   22 
   23 void
   24 dns_ecs_init(dns_ecs_t *ecs) {
   25     isc_netaddr_unspec(&ecs->addr);
   26     ecs->source = 0;
   27     /*
   28      * XXXMUKS: Fix me when resolver ECS gets merged where scope
   29      * gets initialized to 0xff.
   30      */
   31     ecs->scope = 0;
   32 }
   33 
   34 void
   35 dns_ecs_format(dns_ecs_t *ecs, char *buf, size_t size) {
   36     size_t len;
   37 
   38     REQUIRE(ecs != NULL);
   39     REQUIRE(buf != NULL);
   40     REQUIRE(size >= DNS_ECS_FORMATSIZE);
   41 
   42     isc_netaddr_format(&ecs->addr, buf, (unsigned int)size);
   43     len = strlen(buf);
   44     INSIST(size >= len);
   45     buf += len;
   46     size -= len;
   47     snprintf(buf, size, "/%u/%u", ecs->source, ecs->scope);
   48 }