xref: /netbsd-src/external/mpl/bind/dist/lib/dns/clientinfo.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: clientinfo.c,v 1.8 2025/01/26 16:25:22 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 /*! \file */
17 
18 #include <dns/clientinfo.h>
19 #include <dns/ecs.h>
20 
21 void
22 dns_clientinfomethods_init(dns_clientinfomethods_t *methods,
23 			   dns_clientinfo_sourceip_t sourceip) {
24 	methods->version = DNS_CLIENTINFOMETHODS_VERSION;
25 	methods->age = DNS_CLIENTINFOMETHODS_AGE;
26 	methods->sourceip = sourceip;
27 }
28 
29 void
30 dns_clientinfo_init(dns_clientinfo_t *ci, void *data, void *versionp) {
31 	ci->version = DNS_CLIENTINFO_VERSION;
32 	ci->data = data;
33 	ci->dbversion = versionp;
34 	dns_ecs_init(&ci->ecs);
35 }
36 
37 void
38 dns_clientinfo_setecs(dns_clientinfo_t *ci, dns_ecs_t *ecs) {
39 	if (ecs != NULL) {
40 		ci->ecs = *ecs;
41 	} else {
42 		dns_ecs_init(&ci->ecs);
43 	}
44 }
45