2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-27 04:28:33 +00:00
bind/lib/dns/rdata/generic/eui64_109.c
Ondřej Surý 20f0936cf2 Remove use of the inline keyword used as suggestion to compiler
Historically, the inline keyword was a strong suggestion to the compiler
that it should inline the function marked inline.  As compilers became
better at optimising, this functionality has receded, and using inline
as a suggestion to inline a function is obsolete.  The compiler will
happily ignore it and inline something else entirely if it finds that's
a better optimisation.

Therefore, remove all the occurences of the inline keyword with static
functions inside single compilation unit and leave the decision whether
to inline a function or not entirely on the compiler

NOTE: We keep the usage the inline keyword when the purpose is to change
the linkage behaviour.
2022-03-25 08:33:43 +01:00

216 lines
4.6 KiB
C

/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef RDATA_GENERIC_EUI64_109_C
#define RDATA_GENERIC_EUI64_109_C
#include <string.h>
#define RRTYPE_EUI64_ATTRIBUTES (0)
static isc_result_t
fromtext_eui64(ARGS_FROMTEXT) {
isc_token_t token;
unsigned char eui64[8];
unsigned int l0, l1, l2, l3, l4, l5, l6, l7;
int n;
REQUIRE(type == dns_rdatatype_eui64);
UNUSED(type);
UNUSED(rdclass);
UNUSED(origin);
UNUSED(options);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x", &l0,
&l1, &l2, &l3, &l4, &l5, &l6, &l7);
if (n != 8 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U ||
l4 > 255U || l5 > 255U || l6 > 255U || l7 > 255U)
{
return (DNS_R_BADEUI);
}
eui64[0] = l0;
eui64[1] = l1;
eui64[2] = l2;
eui64[3] = l3;
eui64[4] = l4;
eui64[5] = l5;
eui64[6] = l6;
eui64[7] = l7;
return (mem_tobuffer(target, eui64, sizeof(eui64)));
}
static isc_result_t
totext_eui64(ARGS_TOTEXT) {
char buf[sizeof("xx-xx-xx-xx-xx-xx-xx-xx")];
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(rdata->length == 8);
UNUSED(tctx);
(void)snprintf(
buf, sizeof(buf), "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
rdata->data[0], rdata->data[1], rdata->data[2], rdata->data[3],
rdata->data[4], rdata->data[5], rdata->data[6], rdata->data[7]);
return (str_totext(buf, target));
}
static isc_result_t
fromwire_eui64(ARGS_FROMWIRE) {
isc_region_t sregion;
REQUIRE(type == dns_rdatatype_eui64);
UNUSED(type);
UNUSED(options);
UNUSED(rdclass);
UNUSED(dctx);
isc_buffer_activeregion(source, &sregion);
if (sregion.length != 8) {
return (DNS_R_FORMERR);
}
isc_buffer_forward(source, sregion.length);
return (mem_tobuffer(target, sregion.base, sregion.length));
}
static isc_result_t
towire_eui64(ARGS_TOWIRE) {
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(rdata->length == 8);
UNUSED(cctx);
return (mem_tobuffer(target, rdata->data, rdata->length));
}
static int
compare_eui64(ARGS_COMPARE) {
isc_region_t region1;
isc_region_t region2;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == dns_rdatatype_eui64);
REQUIRE(rdata1->length == 8);
REQUIRE(rdata2->length == 8);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
return (isc_region_compare(&region1, &region2));
}
static isc_result_t
fromstruct_eui64(ARGS_FROMSTRUCT) {
dns_rdata_eui64_t *eui64 = source;
REQUIRE(type == dns_rdatatype_eui64);
REQUIRE(eui64 != NULL);
REQUIRE(eui64->common.rdtype == type);
REQUIRE(eui64->common.rdclass == rdclass);
UNUSED(type);
UNUSED(rdclass);
return (mem_tobuffer(target, eui64->eui64, sizeof(eui64->eui64)));
}
static isc_result_t
tostruct_eui64(ARGS_TOSTRUCT) {
dns_rdata_eui64_t *eui64 = target;
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(eui64 != NULL);
REQUIRE(rdata->length == 8);
UNUSED(mctx);
eui64->common.rdclass = rdata->rdclass;
eui64->common.rdtype = rdata->type;
ISC_LINK_INIT(&eui64->common, link);
memmove(eui64->eui64, rdata->data, rdata->length);
return (ISC_R_SUCCESS);
}
static void
freestruct_eui64(ARGS_FREESTRUCT) {
dns_rdata_eui64_t *eui64 = source;
REQUIRE(eui64 != NULL);
REQUIRE(eui64->common.rdtype == dns_rdatatype_eui64);
return;
}
static isc_result_t
additionaldata_eui64(ARGS_ADDLDATA) {
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(rdata->length == 8);
UNUSED(rdata);
UNUSED(owner);
UNUSED(add);
UNUSED(arg);
return (ISC_R_SUCCESS);
}
static isc_result_t
digest_eui64(ARGS_DIGEST) {
isc_region_t r;
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(rdata->length == 8);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
static bool
checkowner_eui64(ARGS_CHECKOWNER) {
REQUIRE(type == dns_rdatatype_eui64);
UNUSED(name);
UNUSED(type);
UNUSED(rdclass);
UNUSED(wildcard);
return (true);
}
static bool
checknames_eui64(ARGS_CHECKNAMES) {
REQUIRE(rdata->type == dns_rdatatype_eui64);
REQUIRE(rdata->length == 8);
UNUSED(rdata);
UNUSED(owner);
UNUSED(bad);
return (true);
}
static int
casecompare_eui64(ARGS_COMPARE) {
return (compare_eui64(rdata1, rdata2));
}
#endif /* RDATA_GENERIC_EUI64_109_C */