aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/dns/resolver_process.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-10-20 09:21:35 -0400
committerDave Barach <dave@barachs.net>2017-10-20 09:34:11 -0400
commitd2080159c4287f3c1d491fa60da2cb6e9ab47b55 (patch)
tree4923b4ba67507f4628084a5a8e459a19c675ea15 /src/vnet/dns/resolver_process.c
parent3491d7f1d05ee5e05ebf0f6129d54c5ca85e22cf (diff)
Add reverse DNS (ip to name) resolution
Change-Id: Ic531d820b1846ff7363e5c396ac0b1176e87b401 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/dns/resolver_process.c')
-rw-r--r--src/vnet/dns/resolver_process.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/vnet/dns/resolver_process.c b/src/vnet/dns/resolver_process.c
index 5603371db52..f473422112f 100644
--- a/src/vnet/dns/resolver_process.c
+++ b/src/vnet/dns/resolver_process.c
@@ -44,6 +44,10 @@ extern int
vnet_dns_response_to_reply (u8 * response,
vl_api_dns_resolve_name_reply_t * rmp,
u32 * min_ttlp);
+extern int
+vnet_dns_response_to_name (u8 * response,
+ vl_api_dns_resolve_ip_reply_t * rmp,
+ u32 * min_ttlp);
static void
resolve_event (dns_main_t * dm, f64 now, u8 * reply)
@@ -95,29 +99,47 @@ resolve_event (dns_main_t * dm, f64 now, u8 * reply)
ep->flags |= DNS_CACHE_ENTRY_FLAG_VALID;
/* Most likely, send 1 message */
- for (i = 0; i < vec_len (ep->api_clients_to_notify); i++)
+ for (i = 0; i < vec_len (ep->pending_api_requests); i++)
{
vl_api_registration_t *regp;
- vl_api_dns_resolve_name_reply_t *rmp;
regp = vl_api_client_index_to_registration
- (ep->api_clients_to_notify[i]);
+ (ep->pending_api_requests[i].client_index);
if (regp == 0)
continue;
- rmp = vl_msg_api_alloc (sizeof (*rmp) + vec_len (ep->dns_response));
- rmp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DNS_RESOLVE_NAME_REPLY);
- rmp->context = ep->api_client_contexts[i];
- min_ttl = ~0;
- rv = vnet_dns_response_to_reply (ep->dns_response, rmp, &min_ttl);
- if (min_ttl != ~0)
- ep->expiration_time = now + min_ttl;
- rmp->retval = clib_host_to_net_u32 (rv);
- vl_msg_api_send (regp, (u8 *) rmp);
+ if (ep->pending_api_requests[i].request_type
+ == DNS_API_PENDING_NAME_TO_IP)
+ {
+ vl_api_dns_resolve_name_reply_t *rmp;
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ rmp->_vl_msg_id =
+ clib_host_to_net_u16 (VL_API_DNS_RESOLVE_NAME_REPLY);
+ rmp->context = ep->pending_api_requests[i].client_context;
+ min_ttl = ~0;
+ rv = vnet_dns_response_to_reply (ep->dns_response, rmp, &min_ttl);
+ if (min_ttl != ~0)
+ ep->expiration_time = now + min_ttl;
+ rmp->retval = clib_host_to_net_u32 (rv);
+ vl_msg_api_send (regp, (u8 *) rmp);
+ }
+ else
+ {
+ vl_api_dns_resolve_ip_reply_t *rmp;
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ rmp->_vl_msg_id =
+ clib_host_to_net_u16 (VL_API_DNS_RESOLVE_IP_REPLY);
+ rmp->context = ep->pending_api_requests[i].client_context;
+ min_ttl = ~0;
+ rv = vnet_dns_response_to_name (ep->dns_response, rmp, &min_ttl);
+ if (min_ttl != ~0)
+ ep->expiration_time = now + min_ttl;
+ rmp->retval = clib_host_to_net_u32 (rv);
+ vl_msg_api_send (regp, (u8 *) rmp);
+ }
}
- vec_free (ep->api_clients_to_notify);
- vec_free (ep->api_client_contexts);
+ vec_free (ep->pending_api_requests);
/* $$$ Add ip4/ip6 reply code */
vec_free (ep->ip4_peers_to_notify);