mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'develop' into rbtree-dict
This commit is contained in:
commit
615878f5b8
|
@ -32,6 +32,7 @@
|
||||||
#include <unbound-event.h>
|
#include <unbound-event.h>
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
#include "util-internal.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* stuff to make it compile pedantically */
|
/* stuff to make it compile pedantically */
|
||||||
|
|
|
@ -463,32 +463,30 @@ getdns_dict *create_getdns_response(struct getdns_dns_req* completed_request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* temporary, cheesy function to reverse an IPv4 address
|
* reverse an IP address for PTR lookup
|
||||||
* and slap "in-addr.arpa" on it. Will replace
|
|
||||||
* XXX
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
reverse_address(char *addr_str)
|
reverse_address(char *addr_str)
|
||||||
{
|
{
|
||||||
char *res_buf;
|
ldns_rdf *addr_rdf;
|
||||||
char *src_start = 0;
|
ldns_rdf *rev_rdf;
|
||||||
char *dest_start;
|
char *rev_str;
|
||||||
|
|
||||||
/* magic number 9 = 3 '.' + 5 'in-addr.arpa' + null terminator */
|
addr_rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A, addr_str);
|
||||||
if ((res_buf = (char *)malloc(strlen(addr_str)+17)) == (char *)0)
|
if (! addr_rdf) {
|
||||||
return 0;
|
addr_rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_AAAA, addr_str);
|
||||||
dest_start=res_buf;
|
if (! addr_rdf)
|
||||||
while ((src_start = strrchr(addr_str, '.')) != 0) {
|
return NULL;
|
||||||
strcpy(dest_start, src_start+1);
|
|
||||||
*src_start = 0;
|
|
||||||
dest_start = dest_start + strlen(dest_start);
|
|
||||||
*dest_start++ = '.';
|
|
||||||
}
|
|
||||||
strcpy(dest_start, addr_str);
|
|
||||||
dest_start = dest_start + strlen(dest_start);
|
|
||||||
strcpy(dest_start, ".in-addr.arpa");
|
|
||||||
|
|
||||||
return res_buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev_rdf = ldns_rdf_address_reverse(addr_rdf);
|
||||||
|
ldns_rdf_deep_free(addr_rdf);
|
||||||
|
if (! rev_rdf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
rev_str = ldns_rdf2str(rev_rdf);
|
||||||
|
ldns_rdf_deep_free(rev_rdf);
|
||||||
|
return rev_str;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue