2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef included_dns_h
17 #define included_dns_h
19 #include <vppinfra/time.h>
20 #include <vppinfra/cache.h>
21 #include <vppinfra/error.h>
23 #include <vppinfra/hash.h>
24 #include <vnet/dns/dns_packet.h>
25 #include <vnet/ip/ip.h>
32 } pending_api_request_t;
34 #define DNS_API_PENDING_NAME_TO_IP 1
35 #define DNS_API_PENDING_IP_TO_NAME 2
42 /** The name in "normal human being" notation, e.g. www.foobar.com */
45 /** For CNAME records, the "next name" to resolve */
48 /** Expiration time */
51 /** Cached dns request, for sending retries */
54 /** Retry parameters */
60 /** Cached dns response */
63 /** Clients awaiting responses */
64 pending_api_request_t *pending_api_requests;
65 ip4_address_t *ip4_peers_to_notify;
66 ip6_address_t *ip6_peers_to_notify;
69 #define DNS_CACHE_ENTRY_FLAG_VALID (1<<0) /**< we have Actual Data */
70 #define DNS_CACHE_ENTRY_FLAG_STATIC (1<<1) /**< static entry */
71 #define DNS_CACHE_ENTRY_FLAG_CNAME (1<<2) /**< CNAME (indirect) entry */
73 #define DNS_RETRIES_PER_SERVER 3
75 #define DNS_RESOLVER_EVENT_RESOLVED 1
76 #define DNS_RESOLVER_EVENT_PENDING 2
81 /** Pool of cache entries */
82 dns_cache_entry_t *entries;
84 /** Pool indices of unresolved entries */
85 u32 *unresolved_entries;
87 /** Find cached record by name */
88 uword *cache_entry_by_name;
91 /** enable / disable flag */
94 /** upstream name servers, e.g. 8.8.8.8 */
95 ip4_address_t *ip4_name_servers;
96 ip6_address_t *ip6_name_servers;
98 /** config parameters */
100 u32 max_ttl_in_seconds;
104 vlib_main_t *vlib_main;
105 vnet_main_t *vnet_main;
108 extern dns_main_t dns_main;
110 extern vlib_node_registration_t dns46_reply_node;
111 extern vlib_node_registration_t dns_resolver_node;
113 #define foreach_dns46_reply_error \
114 _(PROCESSED, "DNS reply pkts processed") \
115 _(NO_ELT, "No DNS pool element") \
116 _(FORMAT_ERROR, "DNS format errors") \
117 _(TEST_DROP, "DNS reply pkt dropped for test purposes")
121 #define _(sym,str) DNS46_REPLY_ERROR_##sym,
122 foreach_dns46_reply_error
125 } dns46_reply_error_t;
127 void vnet_send_dns_request (dns_main_t * dm, dns_cache_entry_t * ep);
129 vnet_dns_cname_indirection_nolock (dns_main_t * dm, u32 ep_index, u8 * reply);
131 int vnet_dns_delete_entry_by_index_nolock (dns_main_t * dm, u32 index);
133 format_function_t format_dns_reply;
136 dns_cache_lock (dns_main_t * dm)
140 while (__sync_lock_test_and_set (dm->cache_lock, 1))
146 dns_cache_unlock (dns_main_t * dm)
150 CLIB_MEMORY_BARRIER ();
155 #endif /* included_dns_h */
158 * fd.io coding-style-patch-verification: ON
161 * eval: (c-set-style "gnu")