1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * SPDX-License-Identifier: MPL-2.0 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 #ifndef DNS_CLIENTINFO_H 15 #define DNS_CLIENTINFO_H 1 16 17 /***** 18 ***** Module Info 19 *****/ 20 21 /*! \file dns/clientinfo.h 22 * \brief 23 * The DNS clientinfo interface allows libdns to retrieve information 24 * about the client from the caller. 25 * 26 * The clientinfo interface is used by the DNS DB and DLZ interfaces; 27 * it allows databases to modify their answers on the basis of information 28 * about the client, such as source IP address. 29 * 30 * dns_clientinfo_t contains a pointer to an opaque structure containing 31 * client information in some form. dns_clientinfomethods_t contains a 32 * list of methods which operate on that opaque structure to return 33 * potentially useful data. Both structures also contain versioning 34 * information. 35 */ 36 37 /***** 38 ***** Imports 39 *****/ 40 41 #include <inttypes.h> 42 43 #include <isc/sockaddr.h> 44 #include <isc/types.h> 45 46 #include <dns/ecs.h> 47 48 ISC_LANG_BEGINDECLS 49 50 /***** 51 ***** Types 52 *****/ 53 54 #define DNS_CLIENTINFO_VERSION 3 55 /* 56 * Any updates to this structure should also be applied in 57 * contrib/modules/dlz/dlz_minmal.h. 58 */ 59 typedef struct dns_clientinfo { 60 uint16_t version; 61 void *data; 62 void *dbversion; 63 dns_ecs_t ecs; 64 } dns_clientinfo_t; 65 66 typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client, 67 isc_sockaddr_t **addrp); 68 69 #define DNS_CLIENTINFOMETHODS_VERSION 2 70 #define DNS_CLIENTINFOMETHODS_AGE 1 71 72 /* 73 * Any updates to this structure should also be applied in 74 * contrib/modules/dlz/dlz_minmal.h. 75 */ 76 typedef struct dns_clientinfomethods { 77 uint16_t version; 78 uint16_t age; 79 dns_clientinfo_sourceip_t sourceip; 80 } dns_clientinfomethods_t; 81 82 /***** 83 ***** Methods 84 *****/ 85 void 86 dns_clientinfomethods_init(dns_clientinfomethods_t *methods, 87 dns_clientinfo_sourceip_t sourceip); 88 89 void 90 dns_clientinfo_init(dns_clientinfo_t *ci, void *data, dns_ecs_t *ecs, 91 void *versionp); 92 93 ISC_LANG_ENDDECLS 94 95 #endif /* DNS_CLIENTINFO_H */ 96