mirror of https://github.com/getdnsapi/getdns.git
Ran indent with the indent.pro committed
This commit is contained in:
parent
eb14f1212d
commit
f8380ff862
|
@ -0,0 +1,19 @@
|
||||||
|
-bap
|
||||||
|
-br
|
||||||
|
-ce
|
||||||
|
-ci4
|
||||||
|
-cli0
|
||||||
|
-d0
|
||||||
|
-di0
|
||||||
|
-i8
|
||||||
|
-ip0
|
||||||
|
-l79
|
||||||
|
-nbc
|
||||||
|
-ncdb
|
||||||
|
-ndj
|
||||||
|
-nfc1
|
||||||
|
-nlp
|
||||||
|
-npcs
|
||||||
|
-psl
|
||||||
|
-sc
|
||||||
|
-sob
|
1231
src/context.c
1231
src/context.c
File diff suppressed because it is too large
Load Diff
|
@ -38,69 +38,72 @@ struct ldns_rbtree_t;
|
||||||
struct getdns_dns_req;
|
struct getdns_dns_req;
|
||||||
|
|
||||||
/** function pointer typedefs */
|
/** function pointer typedefs */
|
||||||
typedef void (*getdns_update_callback)(getdns_context_t context, uint16_t changed_item);
|
typedef void (*getdns_update_callback) (getdns_context_t context,
|
||||||
typedef void* (*getdns_memory_allocator)(size_t size);
|
uint16_t changed_item);
|
||||||
typedef void (*getdns_memory_deallocator)(void*);
|
typedef void *(*getdns_memory_allocator) (size_t size);
|
||||||
typedef void* (*getdns_memory_reallocator)(void* ptr, size_t size);
|
typedef void (*getdns_memory_deallocator) (void *);
|
||||||
|
typedef void *(*getdns_memory_reallocator) (void *ptr, size_t size);
|
||||||
|
|
||||||
struct getdns_context_t {
|
struct getdns_context_t
|
||||||
|
{
|
||||||
|
|
||||||
/* Context values */
|
/* Context values */
|
||||||
uint16_t resolution_type;
|
uint16_t resolution_type;
|
||||||
uint16_t *namespaces;
|
uint16_t *namespaces;
|
||||||
uint16_t timeout;
|
uint16_t timeout;
|
||||||
uint16_t follow_redirects;
|
uint16_t follow_redirects;
|
||||||
struct getdns_list *dns_root_servers;
|
struct getdns_list *dns_root_servers;
|
||||||
uint16_t append_name;
|
uint16_t append_name;
|
||||||
struct getdns_list *suffix;
|
struct getdns_list *suffix;
|
||||||
struct getdns_list *dnssec_trust_anchors;
|
struct getdns_list *dnssec_trust_anchors;
|
||||||
struct getdns_list *upstream_list;
|
struct getdns_list *upstream_list;
|
||||||
|
|
||||||
uint8_t edns_extended_rcode;
|
uint8_t edns_extended_rcode;
|
||||||
uint8_t edns_version;
|
uint8_t edns_version;
|
||||||
uint8_t edns_do_bit;
|
uint8_t edns_do_bit;
|
||||||
|
|
||||||
getdns_update_callback update_callback;
|
getdns_update_callback update_callback;
|
||||||
getdns_memory_allocator memory_allocator;
|
getdns_memory_allocator memory_allocator;
|
||||||
getdns_memory_deallocator memory_deallocator;
|
getdns_memory_deallocator memory_deallocator;
|
||||||
getdns_memory_reallocator memory_reallocator;
|
getdns_memory_reallocator memory_reallocator;
|
||||||
|
|
||||||
/* Event loop for sync requests */
|
/* Event loop for sync requests */
|
||||||
struct event_base* event_base_sync;
|
struct event_base *event_base_sync;
|
||||||
/* Event loop for async requests */
|
/* Event loop for async requests */
|
||||||
struct event_base* event_base_async;
|
struct event_base *event_base_async;
|
||||||
|
|
||||||
/* The underlying unbound contexts that do
|
/* The underlying unbound contexts that do
|
||||||
the real work */
|
* the real work */
|
||||||
struct ub_ctx *unbound_sync;
|
struct ub_ctx *unbound_sync;
|
||||||
struct ub_ctx *unbound_async;
|
struct ub_ctx *unbound_async;
|
||||||
|
|
||||||
/* which resolution type the contexts are configured for
|
/* which resolution type the contexts are configured for
|
||||||
* 0 means nothing set
|
* 0 means nothing set
|
||||||
*/
|
*/
|
||||||
uint8_t resolution_type_set;
|
uint8_t resolution_type_set;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* outbound requests -> transaction to getdns_dns_req
|
* outbound requests -> transaction to getdns_dns_req
|
||||||
*/
|
*/
|
||||||
struct ldns_rbtree_t* outbound_requests;
|
struct ldns_rbtree_t *outbound_requests;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
/** internal functions **/
|
/** internal functions **/
|
||||||
/**
|
/**
|
||||||
* Sets up the unbound contexts with stub or recursive behavior
|
* Sets up the unbound contexts with stub or recursive behavior
|
||||||
* if needed.
|
* if needed.
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_context_prepare_for_resolution(getdns_context_t context);
|
getdns_return_t getdns_context_prepare_for_resolution(getdns_context_t
|
||||||
|
context);
|
||||||
|
|
||||||
/* track an outbound request */
|
/* track an outbound request */
|
||||||
getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req* req);
|
getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req
|
||||||
|
*req);
|
||||||
/* clear the outbound request from being tracked - does not cancel it */
|
/* clear the outbound request from being tracked - does not cancel it */
|
||||||
getdns_return_t getdns_context_clear_outbound_request(struct getdns_dns_req* req);
|
getdns_return_t getdns_context_clear_outbound_request(struct getdns_dns_req
|
||||||
|
*req);
|
||||||
/* cancel callback internal - flag to indicate if req should be freed and callback fired */
|
/* cancel callback internal - flag to indicate if req should be freed and callback fired */
|
||||||
getdns_return_t getdns_context_cancel_request(getdns_context_t context,
|
getdns_return_t getdns_context_cancel_request(getdns_context_t context,
|
||||||
getdns_transaction_t transaction_id,
|
getdns_transaction_t transaction_id, int fire_callback);
|
||||||
int fire_callback);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
121
src/convert.c
121
src/convert.c
|
@ -38,73 +38,76 @@
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getdns_convert_dns_name_to_fqdn(
|
getdns_convert_dns_name_to_fqdn(char *name_from_dns_response)
|
||||||
char *name_from_dns_response
|
|
||||||
)
|
|
||||||
{ UNUSED_PARAM(name_from_dns_response); return NULL; }
|
|
||||||
|
|
||||||
char *
|
|
||||||
getdns_convert_fqdn_to_dns_name(
|
|
||||||
char *fqdn_as_string
|
|
||||||
)
|
|
||||||
{ UNUSED_PARAM(fqdn_as_string); return NULL; }
|
|
||||||
|
|
||||||
char *
|
|
||||||
getdns_convert_ulabel_to_alabel(
|
|
||||||
char *ulabel
|
|
||||||
)
|
|
||||||
{ UNUSED_PARAM(ulabel); return NULL; }
|
|
||||||
|
|
||||||
char *
|
|
||||||
getdns_convert_alabel_to_ulabel(
|
|
||||||
char *alabel
|
|
||||||
)
|
|
||||||
{ UNUSED_PARAM(alabel); return NULL; }
|
|
||||||
|
|
||||||
char *
|
|
||||||
getdns_display_ip_address(
|
|
||||||
struct getdns_bindata *bindata_of_ipv4_or_ipv6_address
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
char buff[256];
|
UNUSED_PARAM(name_from_dns_response);
|
||||||
if (!bindata_of_ipv4_or_ipv6_address ||
|
return NULL;
|
||||||
bindata_of_ipv4_or_ipv6_address->size == 0 ||
|
}
|
||||||
!bindata_of_ipv4_or_ipv6_address->data) {
|
|
||||||
return NULL;
|
char *
|
||||||
}
|
getdns_convert_fqdn_to_dns_name(char *fqdn_as_string)
|
||||||
if (bindata_of_ipv4_or_ipv6_address->size == 4) {
|
{
|
||||||
const char* ipStr = inet_ntop(AF_INET,
|
UNUSED_PARAM(fqdn_as_string);
|
||||||
bindata_of_ipv4_or_ipv6_address->data,
|
return NULL;
|
||||||
buff,
|
}
|
||||||
256);
|
|
||||||
if (ipStr) {
|
char *
|
||||||
return strdup(ipStr);
|
getdns_convert_ulabel_to_alabel(char *ulabel)
|
||||||
}
|
{
|
||||||
} else if (bindata_of_ipv4_or_ipv6_address->size == 16) {
|
UNUSED_PARAM(ulabel);
|
||||||
const char* ipStr = inet_ntop(AF_INET6,
|
return NULL;
|
||||||
bindata_of_ipv4_or_ipv6_address->data,
|
}
|
||||||
buff,
|
|
||||||
256);
|
char *
|
||||||
if (ipStr) {
|
getdns_convert_alabel_to_ulabel(char *alabel)
|
||||||
return strdup(ipStr);
|
{
|
||||||
}
|
UNUSED_PARAM(alabel);
|
||||||
}
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
getdns_display_ip_address(struct getdns_bindata
|
||||||
|
*bindata_of_ipv4_or_ipv6_address)
|
||||||
|
{
|
||||||
|
char buff[256];
|
||||||
|
if (!bindata_of_ipv4_or_ipv6_address ||
|
||||||
|
bindata_of_ipv4_or_ipv6_address->size == 0 ||
|
||||||
|
!bindata_of_ipv4_or_ipv6_address->data) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (bindata_of_ipv4_or_ipv6_address->size == 4) {
|
||||||
|
const char *ipStr = inet_ntop(AF_INET,
|
||||||
|
bindata_of_ipv4_or_ipv6_address->data,
|
||||||
|
buff,
|
||||||
|
256);
|
||||||
|
if (ipStr) {
|
||||||
|
return strdup(ipStr);
|
||||||
|
}
|
||||||
|
} else if (bindata_of_ipv4_or_ipv6_address->size == 16) {
|
||||||
|
const char *ipStr = inet_ntop(AF_INET6,
|
||||||
|
bindata_of_ipv4_or_ipv6_address->data,
|
||||||
|
buff,
|
||||||
|
256);
|
||||||
|
if (ipStr) {
|
||||||
|
return strdup(ipStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_strerror(getdns_return_t err, char *buf, size_t buflen)
|
getdns_strerror(getdns_return_t err, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_GOOD;
|
getdns_return_t retval = GETDNS_RETURN_GOOD;
|
||||||
|
|
||||||
const char* err_str = getdns_get_errorstr_by_id(err);
|
const char *err_str = getdns_get_errorstr_by_id(err);
|
||||||
if (!err_str) {
|
if (!err_str) {
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf, buflen, "%s", err_str);
|
snprintf(buf, buflen, "%s", err_str);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_strerror */
|
} /* getdns_strerror */
|
||||||
|
|
||||||
/* getdns_core_only.c */
|
/* getdns_core_only.c */
|
||||||
|
|
901
src/dict.c
901
src/dict.c
File diff suppressed because it is too large
Load Diff
26
src/dict.h
26
src/dict.h
|
@ -38,20 +38,22 @@
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
#include <ldns/rbtree.h>
|
#include <ldns/rbtree.h>
|
||||||
|
|
||||||
union getdns_item {
|
union getdns_item
|
||||||
struct getdns_list *list;
|
{
|
||||||
struct getdns_dict *dict;
|
struct getdns_list *list;
|
||||||
uint32_t n;
|
struct getdns_dict *dict;
|
||||||
struct getdns_bindata *bindata;
|
uint32_t n;
|
||||||
|
struct getdns_bindata *bindata;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this structure represents a single item in a dictionary type
|
* this structure represents a single item in a dictionary type
|
||||||
*/
|
*/
|
||||||
struct getdns_dict_item {
|
struct getdns_dict_item
|
||||||
ldns_rbnode_t node;
|
{
|
||||||
getdns_data_type dtype;
|
ldns_rbnode_t node;
|
||||||
union getdns_item data;
|
getdns_data_type dtype;
|
||||||
|
union getdns_item data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +63,11 @@ struct getdns_dict_item {
|
||||||
* trees in the std library. The internal implementation may change so the
|
* trees in the std library. The internal implementation may change so the
|
||||||
* application should stick to the helper functions.
|
* application should stick to the helper functions.
|
||||||
*/
|
*/
|
||||||
struct getdns_dict {
|
struct getdns_dict
|
||||||
ldns_rbtree_t root;
|
{
|
||||||
|
ldns_rbtree_t root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* dict.h */
|
/* dict.h */
|
||||||
|
|
|
@ -10,285 +10,187 @@
|
||||||
|
|
||||||
/* The return values */
|
/* The return values */
|
||||||
getdns_return_t retregular;
|
getdns_return_t retregular;
|
||||||
char * retcharstar;
|
char *retcharstar;
|
||||||
|
|
||||||
/* The args */
|
/* The args */
|
||||||
bool boolarg;
|
bool boolarg;
|
||||||
char * charstararg;
|
char *charstararg;
|
||||||
getdns_callback_t callbackarg;
|
getdns_callback_t callbackarg;
|
||||||
uint16_t regulararg;
|
uint16_t regulararg;
|
||||||
uint16_t *regularptrarg;
|
uint16_t *regularptrarg;
|
||||||
getdns_transaction_t txidarg;
|
getdns_transaction_t txidarg;
|
||||||
getdns_transaction_t * txidptrarg;
|
getdns_transaction_t *txidptrarg;
|
||||||
|
|
||||||
getdns_data_type * datatypeptrarg;
|
getdns_data_type *datatypeptrarg;
|
||||||
struct getdns_bindata ** bindataptrarg;
|
struct getdns_bindata **bindataptrarg;
|
||||||
struct getdns_dict * dictarg;
|
struct getdns_dict *dictarg;
|
||||||
struct getdns_bindata * bindataarg;
|
struct getdns_bindata *bindataarg;
|
||||||
struct getdns_list * listarg;
|
struct getdns_list *listarg;
|
||||||
struct getdns_dict ** dictptrarg;
|
struct getdns_dict **dictptrarg;
|
||||||
struct getdns_list ** listptrarg;
|
struct getdns_list **listptrarg;
|
||||||
|
|
||||||
size_t sizetarg;
|
size_t sizetarg;
|
||||||
size_t * sizetptrarg;
|
size_t *sizetptrarg;
|
||||||
getdns_context_t contextarg = NULL;
|
getdns_context_t contextarg = NULL;
|
||||||
uint8_t uint8arg;
|
uint8_t uint8arg;
|
||||||
uint16_t uint16arg;
|
uint16_t uint16arg;
|
||||||
uint32_t uint32arg;
|
uint32_t uint32arg;
|
||||||
uint8_t * uint8ptrarg;
|
uint8_t *uint8ptrarg;
|
||||||
uint16_t * uint16ptrarg;
|
uint16_t *uint16ptrarg;
|
||||||
uint32_t * uint32ptrarg;
|
uint32_t *uint32ptrarg;
|
||||||
void * arrayarg;
|
void *arrayarg;
|
||||||
void allocfunctionarg(size_t foo) {UNUSED_PARAM(foo);}
|
void
|
||||||
void deallocfunctionarg(void* foo) {UNUSED_PARAM(foo);}
|
allocfunctionarg(size_t foo)
|
||||||
void setcallbackfunctionarg(struct getdns_context_t *foo1, uint16_t foo2)
|
{
|
||||||
{UNUSED_PARAM(foo1);UNUSED_PARAM(foo2);}
|
UNUSED_PARAM(foo);
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
void
|
||||||
|
deallocfunctionarg(void *foo)
|
||||||
|
{
|
||||||
|
UNUSED_PARAM(foo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setcallbackfunctionarg(struct getdns_context_t *foo1, uint16_t foo2)
|
||||||
|
{
|
||||||
|
UNUSED_PARAM(foo1);
|
||||||
|
UNUSED_PARAM(foo2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
|
|
||||||
retregular = getdns_general(
|
retregular = getdns_general(contextarg,
|
||||||
contextarg,
|
charstararg,
|
||||||
charstararg,
|
uint16arg, dictarg, arrayarg, txidptrarg, callbackarg);
|
||||||
uint16arg,
|
|
||||||
dictarg,
|
|
||||||
arrayarg,
|
|
||||||
txidptrarg,
|
|
||||||
callbackarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_address(
|
retregular = getdns_address(contextarg,
|
||||||
contextarg,
|
charstararg, dictarg, arrayarg, txidptrarg, callbackarg);
|
||||||
charstararg,
|
|
||||||
dictarg,
|
|
||||||
arrayarg,
|
|
||||||
txidptrarg,
|
|
||||||
callbackarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_hostname(
|
retregular = getdns_hostname(contextarg,
|
||||||
contextarg,
|
dictarg, dictarg, arrayarg, txidptrarg, callbackarg);
|
||||||
dictarg,
|
|
||||||
dictarg,
|
|
||||||
arrayarg,
|
|
||||||
txidptrarg,
|
|
||||||
callbackarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_service(
|
retregular = getdns_service(contextarg,
|
||||||
contextarg,
|
charstararg, dictarg, arrayarg, txidptrarg, callbackarg);
|
||||||
charstararg,
|
|
||||||
dictarg,
|
|
||||||
arrayarg,
|
|
||||||
txidptrarg,
|
|
||||||
callbackarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_create(
|
retregular = getdns_context_create(&contextarg, boolarg);
|
||||||
&contextarg,
|
|
||||||
boolarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_cancel_callback(
|
retregular = getdns_cancel_callback(contextarg, txidarg);
|
||||||
contextarg,
|
|
||||||
txidarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_general_sync(
|
retregular = getdns_general_sync(contextarg,
|
||||||
contextarg,
|
charstararg, uint16arg, dictarg, uint32ptrarg, &dictarg);
|
||||||
charstararg,
|
|
||||||
uint16arg,
|
|
||||||
dictarg,
|
|
||||||
uint32ptrarg,
|
|
||||||
&dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_address_sync(
|
retregular = getdns_address_sync(contextarg,
|
||||||
contextarg,
|
charstararg, dictarg, uint32ptrarg, &dictarg);
|
||||||
charstararg,
|
|
||||||
dictarg,
|
|
||||||
uint32ptrarg,
|
|
||||||
&dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_hostname_sync(
|
retregular = getdns_hostname_sync(contextarg,
|
||||||
contextarg,
|
dictarg, dictarg, uint32ptrarg, &dictarg);
|
||||||
dictarg,
|
|
||||||
dictarg,
|
|
||||||
uint32ptrarg,
|
|
||||||
&dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_service_sync(
|
retregular = getdns_service_sync(contextarg,
|
||||||
contextarg,
|
charstararg, dictarg, uint32ptrarg, &dictarg);
|
||||||
charstararg,
|
|
||||||
dictarg,
|
|
||||||
uint32ptrarg,
|
|
||||||
&dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_free_sync_request_memory(
|
getdns_free_sync_request_memory(dictarg);
|
||||||
dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_list_get_length(listarg, sizetptrarg);
|
retregular = getdns_list_get_length(listarg, sizetptrarg);
|
||||||
retregular = getdns_list_get_data_type(listarg, sizetarg, datatypeptrarg);
|
retregular =
|
||||||
retregular = getdns_list_get_dict(listarg, sizetarg, dictptrarg);
|
getdns_list_get_data_type(listarg, sizetarg, datatypeptrarg);
|
||||||
retregular = getdns_list_get_list(listarg, sizetarg, listptrarg);
|
retregular = getdns_list_get_dict(listarg, sizetarg, dictptrarg);
|
||||||
retregular = getdns_list_get_bindata(listarg, sizetarg, bindataptrarg);
|
retregular = getdns_list_get_list(listarg, sizetarg, listptrarg);
|
||||||
retregular = getdns_list_get_int(listarg, sizetarg, uint32ptrarg);
|
retregular = getdns_list_get_bindata(listarg, sizetarg, bindataptrarg);
|
||||||
|
retregular = getdns_list_get_int(listarg, sizetarg, uint32ptrarg);
|
||||||
|
|
||||||
retregular = getdns_dict_get_names(dictarg, listptrarg);
|
retregular = getdns_dict_get_names(dictarg, listptrarg);
|
||||||
retregular = getdns_dict_get_data_type(dictarg, charstararg, datatypeptrarg);
|
retregular =
|
||||||
retregular = getdns_dict_get_dict(dictarg, charstararg, dictptrarg);
|
getdns_dict_get_data_type(dictarg, charstararg, datatypeptrarg);
|
||||||
retregular = getdns_dict_get_list(dictarg, charstararg, listptrarg);
|
retregular = getdns_dict_get_dict(dictarg, charstararg, dictptrarg);
|
||||||
retregular = getdns_dict_get_bindata(dictarg, charstararg, bindataptrarg);
|
retregular = getdns_dict_get_list(dictarg, charstararg, listptrarg);
|
||||||
retregular = getdns_dict_get_int(dictarg, charstararg, uint32ptrarg);
|
retregular =
|
||||||
|
getdns_dict_get_bindata(dictarg, charstararg, bindataptrarg);
|
||||||
|
retregular = getdns_dict_get_int(dictarg, charstararg, uint32ptrarg);
|
||||||
|
|
||||||
listarg = getdns_list_create();
|
listarg = getdns_list_create();
|
||||||
retregular = getdns_list_set_dict(listarg, sizetarg, dictarg);
|
retregular = getdns_list_set_dict(listarg, sizetarg, dictarg);
|
||||||
retregular = getdns_list_set_list(listarg, sizetarg, listarg);
|
retregular = getdns_list_set_list(listarg, sizetarg, listarg);
|
||||||
retregular = getdns_list_set_bindata(listarg, sizetarg, bindataarg);
|
retregular = getdns_list_set_bindata(listarg, sizetarg, bindataarg);
|
||||||
retregular = getdns_list_set_int(listarg, sizetarg, uint32arg);
|
retregular = getdns_list_set_int(listarg, sizetarg, uint32arg);
|
||||||
|
|
||||||
dictarg = getdns_dict_create();
|
dictarg = getdns_dict_create();
|
||||||
retregular = getdns_dict_set_dict(dictarg, charstararg, dictarg);
|
retregular = getdns_dict_set_dict(dictarg, charstararg, dictarg);
|
||||||
retregular = getdns_dict_set_list(dictarg, charstararg, listarg);
|
retregular = getdns_dict_set_list(dictarg, charstararg, listarg);
|
||||||
retregular = getdns_dict_set_bindata(dictarg, charstararg, bindataarg);
|
retregular = getdns_dict_set_bindata(dictarg, charstararg, bindataarg);
|
||||||
retregular = getdns_dict_set_int(dictarg, charstararg, uint32arg);
|
retregular = getdns_dict_set_int(dictarg, charstararg, uint32arg);
|
||||||
retcharstar = getdns_pretty_print_dict(
|
retcharstar = getdns_pretty_print_dict(dictarg);
|
||||||
dictarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retcharstar = getdns_convert_fqdn_to_dns_name(
|
retcharstar = getdns_convert_fqdn_to_dns_name(charstararg);
|
||||||
charstararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retcharstar = getdns_convert_dns_name_to_fqdn(
|
retcharstar = getdns_convert_dns_name_to_fqdn(charstararg);
|
||||||
charstararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retcharstar = getdns_convert_ulabel_to_alabel(
|
retcharstar = getdns_convert_ulabel_to_alabel(charstararg);
|
||||||
charstararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retcharstar = getdns_convert_alabel_to_ulabel(
|
retcharstar = getdns_convert_alabel_to_ulabel(charstararg);
|
||||||
charstararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_validate_dnssec(
|
retregular = getdns_validate_dnssec(bindataarg, listarg, listarg);
|
||||||
bindataarg,
|
|
||||||
listarg,
|
|
||||||
listarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retcharstar = getdns_display_ip_address(
|
retcharstar = getdns_display_ip_address(bindataarg);
|
||||||
bindataarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_context_update_callback(
|
retregular = getdns_context_set_context_update_callback(contextarg,
|
||||||
contextarg,
|
setcallbackfunctionarg);
|
||||||
setcallbackfunctionarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_resolution_type(
|
retregular = getdns_context_set_resolution_type(contextarg,
|
||||||
contextarg,
|
regulararg);
|
||||||
regulararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_namespaces(
|
retregular = getdns_context_set_namespaces(contextarg,
|
||||||
contextarg,
|
sizetarg, regularptrarg);
|
||||||
sizetarg,
|
|
||||||
regularptrarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_dns_transport(
|
retregular = getdns_context_set_dns_transport(contextarg, regulararg);
|
||||||
contextarg,
|
|
||||||
regulararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_limit_outstanding_queries(
|
retregular = getdns_context_set_limit_outstanding_queries(contextarg,
|
||||||
contextarg,
|
uint16arg);
|
||||||
uint16arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_timeout(
|
retregular = getdns_context_set_timeout(contextarg, uint16arg);
|
||||||
contextarg,
|
|
||||||
uint16arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_follow_redirects(
|
retregular = getdns_context_set_follow_redirects(contextarg,
|
||||||
contextarg,
|
regulararg);
|
||||||
regulararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_dns_root_servers(
|
retregular = getdns_context_set_dns_root_servers(contextarg, listarg);
|
||||||
contextarg,
|
|
||||||
listarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_append_name(
|
retregular = getdns_context_set_append_name(contextarg, regulararg);
|
||||||
contextarg,
|
|
||||||
regulararg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_suffix(
|
retregular = getdns_context_set_suffix(contextarg, listarg);
|
||||||
contextarg,
|
|
||||||
listarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_dnssec_trust_anchors(
|
retregular = getdns_context_set_dnssec_trust_anchors(contextarg,
|
||||||
contextarg,
|
listarg);
|
||||||
listarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_dnssec_allowed_skew(
|
retregular = getdns_context_set_dnssec_allowed_skew(contextarg,
|
||||||
contextarg,
|
uint16arg);
|
||||||
uint16arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_stub_resolution(
|
retregular = getdns_context_set_stub_resolution(contextarg, listarg);
|
||||||
contextarg,
|
|
||||||
listarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_edns_maximum_udp_payload_size(
|
retregular =
|
||||||
contextarg,
|
getdns_context_set_edns_maximum_udp_payload_size(contextarg,
|
||||||
uint16arg
|
uint16arg);
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_edns_extended_rcode(
|
retregular = getdns_context_set_edns_extended_rcode(contextarg,
|
||||||
contextarg,
|
uint8arg);
|
||||||
uint8arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_edns_version(
|
retregular = getdns_context_set_edns_version(contextarg, uint8arg);
|
||||||
contextarg,
|
|
||||||
uint8arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_edns_do_bit(
|
retregular = getdns_context_set_edns_do_bit(contextarg, uint8arg);
|
||||||
contextarg,
|
|
||||||
uint8arg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_memory_allocator(
|
retregular = getdns_context_set_memory_allocator(contextarg,
|
||||||
contextarg,
|
allocfunctionarg);
|
||||||
allocfunctionarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_memory_deallocator(
|
retregular = getdns_context_set_memory_deallocator(contextarg,
|
||||||
contextarg,
|
deallocfunctionarg);
|
||||||
deallocfunctionarg
|
|
||||||
);
|
|
||||||
|
|
||||||
retregular = getdns_context_set_memory_reallocator(
|
retregular = getdns_context_set_memory_reallocator(contextarg,
|
||||||
contextarg,
|
deallocfunctionarg);
|
||||||
deallocfunctionarg
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_list_destroy(listarg);
|
getdns_list_destroy(listarg);
|
||||||
getdns_dict_destroy(dictarg);
|
getdns_dict_destroy(dictarg);
|
||||||
getdns_context_destroy(contextarg);
|
getdns_context_destroy(contextarg);
|
||||||
|
|
||||||
return(0); } /* End of main() */
|
return (0);
|
||||||
|
} /* End of main() */
|
||||||
|
|
|
@ -37,56 +37,64 @@
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
/* Set up the callback function, which will also do the processing of the results */
|
/* Set up the callback function, which will also do the processing of the results */
|
||||||
void this_callbackfn(struct getdns_context_t *this_context,
|
void
|
||||||
uint16_t this_callback_type,
|
this_callbackfn(struct getdns_context_t *this_context,
|
||||||
struct getdns_dict *this_response,
|
uint16_t this_callback_type,
|
||||||
void *this_userarg,
|
struct getdns_dict *this_response,
|
||||||
getdns_transaction_t this_transaction_id)
|
void *this_userarg, getdns_transaction_t this_transaction_id)
|
||||||
{
|
{
|
||||||
UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
|
UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
|
||||||
UNUSED_PARAM(this_context); /* Not looking at the context for this example */
|
UNUSED_PARAM(this_context); /* Not looking at the context for this example */
|
||||||
getdns_return_t this_ret; /* Holder for all function returns */
|
getdns_return_t this_ret; /* Holder for all function returns */
|
||||||
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
|
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */
|
||||||
{
|
|
||||||
/* Be sure the search returned something */
|
/* Be sure the search returned something */
|
||||||
uint32_t this_error;
|
uint32_t this_error;
|
||||||
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
||||||
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
||||||
{
|
{
|
||||||
fprintf(stderr, "The search had no results, and a return value of %d. Exiting.\n", this_error);
|
fprintf(stderr,
|
||||||
|
"The search had no results, and a return value of %d. Exiting.\n",
|
||||||
|
this_error);
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct getdns_list * just_the_addresses_ptr;
|
struct getdns_list *just_the_addresses_ptr;
|
||||||
this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr);
|
this_ret =
|
||||||
if (this_ret != GETDNS_RETURN_GOOD) // This check is really not needed, but prevents a compiler error under "pedantic"
|
getdns_dict_get_list(this_response, "just_address_answers",
|
||||||
|
&just_the_addresses_ptr);
|
||||||
|
if (this_ret != GETDNS_RETURN_GOOD) // This check is really not needed, but prevents a compiler error under "pedantic"
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Trying to get the answers failed: %d\n", this_ret);
|
fprintf(stderr,
|
||||||
|
"Trying to get the answers failed: %d\n",
|
||||||
|
this_ret);
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t num_addresses = 0;
|
size_t num_addresses = 0;
|
||||||
this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
|
this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
|
||||||
/* Go through each record */
|
/* Go through each record */
|
||||||
if (num_addresses == 0) {
|
if (num_addresses == 0) {
|
||||||
fprintf(stderr, "There are no addresses.\n");
|
fprintf(stderr, "There are no addresses.\n");
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for ( size_t rec_count = 0; rec_count < num_addresses; ++rec_count )
|
for (size_t rec_count = 0; rec_count < num_addresses;
|
||||||
{
|
++rec_count) {
|
||||||
struct getdns_bindata * this_address_data;
|
struct getdns_bindata *this_address_data;
|
||||||
char* ipAddr = NULL;
|
char *ipAddr = NULL;
|
||||||
this_ret = getdns_list_get_bindata(just_the_addresses_ptr, rec_count, &this_address_data); // Ignore any error
|
this_ret = getdns_list_get_bindata(just_the_addresses_ptr, rec_count, &this_address_data); // Ignore any error
|
||||||
ipAddr = getdns_display_ip_address(this_address_data);
|
ipAddr = getdns_display_ip_address(this_address_data);
|
||||||
printf("The address is %s\n", ipAddr);
|
printf("The address is %s\n", ipAddr);
|
||||||
free(ipAddr);
|
free(ipAddr);
|
||||||
}
|
}
|
||||||
}
|
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
||||||
else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
fprintf(stderr,
|
||||||
fprintf(stderr, "The callback with ID %"PRIu64" was cancelled. Exiting.\n", this_transaction_id);
|
"The callback with ID %" PRIu64
|
||||||
|
" was cancelled. Exiting.\n", this_transaction_id);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "The callback got a callback_type of %d. Exiting.\n", this_callback_type);
|
fprintf(stderr,
|
||||||
|
"The callback got a callback_type of %d. Exiting.\n",
|
||||||
|
this_callback_type);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
|
@ -97,41 +105,41 @@ main()
|
||||||
{
|
{
|
||||||
/* Create the DNS context for this call */
|
/* Create the DNS context for this call */
|
||||||
struct getdns_context_t *this_context = NULL;
|
struct getdns_context_t *this_context = NULL;
|
||||||
getdns_return_t context_create_return = getdns_context_create(&this_context, true);
|
getdns_return_t context_create_return =
|
||||||
if (context_create_return != GETDNS_RETURN_GOOD)
|
getdns_context_create(&this_context, true);
|
||||||
{
|
if (context_create_return != GETDNS_RETURN_GOOD) {
|
||||||
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
|
fprintf(stderr, "Trying to create the context failed: %d",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
context_create_return);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
/* Create an event base and put it in the context using the unknown function name */
|
/* Create an event base and put it in the context using the unknown function name */
|
||||||
struct event_base *this_event_base;
|
struct event_base *this_event_base;
|
||||||
this_event_base = event_base_new();
|
this_event_base = event_base_new();
|
||||||
if (this_event_base == NULL)
|
if (this_event_base == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Trying to create the event base failed.\n");
|
fprintf(stderr, "Trying to create the event base failed.\n");
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
(void)getdns_extension_set_libevent_base(this_context, this_event_base);
|
(void) getdns_extension_set_libevent_base(this_context,
|
||||||
|
this_event_base);
|
||||||
/* Set up the getdns call */
|
/* Set up the getdns call */
|
||||||
const char * this_name = "www.example.com";
|
const char *this_name = "www.example.com";
|
||||||
char* this_userarg = "somestring"; // Could add things here to help identify this call
|
char *this_userarg = "somestring"; // Could add things here to help identify this call
|
||||||
getdns_transaction_t this_transaction_id = 0;
|
getdns_transaction_t this_transaction_id = 0;
|
||||||
|
|
||||||
// getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
// getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
||||||
|
|
||||||
/* Make the call */
|
/* Make the call */
|
||||||
getdns_return_t dns_request_return = getdns_address(this_context, this_name,
|
getdns_return_t dns_request_return =
|
||||||
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
getdns_address(this_context, this_name,
|
||||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
||||||
{
|
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.\n", this_name);
|
fprintf(stderr, "A bad domain name was used: %s. Exiting.\n",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
this_name);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
} else if (dns_request_return != GETDNS_RETURN_GOOD) {
|
} else if (dns_request_return != GETDNS_RETURN_GOOD) {
|
||||||
fprintf(stderr, "The context is not setup properly.\n");
|
fprintf(stderr, "The context is not setup properly.\n");
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Call the event loop */
|
/* Call the event loop */
|
||||||
int dispatch_return = event_base_dispatch(this_event_base);
|
int dispatch_return = event_base_dispatch(this_event_base);
|
||||||
UNUSED_PARAM(dispatch_return);
|
UNUSED_PARAM(dispatch_return);
|
||||||
|
@ -142,6 +150,6 @@ main()
|
||||||
event_base_free(this_event_base);
|
event_base_free(this_event_base);
|
||||||
/* Assuming we get here, leave gracefully */
|
/* Assuming we get here, leave gracefully */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* example-simple-answers.c */
|
/* example-simple-answers.c */
|
||||||
|
|
|
@ -35,73 +35,79 @@
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
getdns_return_t context_create_return;
|
getdns_return_t context_create_return;
|
||||||
struct getdns_list *just_the_addresses_ptr;
|
struct getdns_list *just_the_addresses_ptr;
|
||||||
size_t num_addresses = 0;
|
size_t num_addresses = 0;
|
||||||
size_t rec_count;
|
size_t rec_count;
|
||||||
struct getdns_bindata *this_address_data;
|
struct getdns_bindata *this_address_data;
|
||||||
struct getdns_context_t *this_context = NULL;
|
struct getdns_context_t *this_context = NULL;
|
||||||
uint32_t this_error = 0;
|
uint32_t this_error = 0;
|
||||||
struct getdns_dict *this_extensions = NULL;
|
struct getdns_dict *this_extensions = NULL;
|
||||||
const char *this_name = "www.example.com";
|
const char *this_name = "www.example.com";
|
||||||
uint8_t this_request_type = GETDNS_RRTYPE_A;
|
uint8_t this_request_type = GETDNS_RRTYPE_A;
|
||||||
struct getdns_dict *this_response = NULL;
|
struct getdns_dict *this_response = NULL;
|
||||||
uint32_t this_response_length;
|
uint32_t this_response_length;
|
||||||
getdns_return_t this_ret;
|
getdns_return_t this_ret;
|
||||||
|
|
||||||
/* Create the DNS context for this call */
|
/* Create the DNS context for this call */
|
||||||
context_create_return = getdns_context_create(&this_context, true);
|
context_create_return = getdns_context_create(&this_context, true);
|
||||||
if (context_create_return != GETDNS_RETURN_GOOD)
|
if (context_create_return != GETDNS_RETURN_GOOD) {
|
||||||
{
|
fprintf(stderr, "Trying to create the context failed: %d",
|
||||||
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
|
context_create_return);
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the getdns_sync_request call */
|
/* Set up the getdns_sync_request call */
|
||||||
/* Get the A and AAAA records */
|
/* Get the A and AAAA records */
|
||||||
this_extensions = getdns_dict_create();
|
this_extensions = getdns_dict_create();
|
||||||
this_ret = getdns_dict_set_int(this_extensions, "return_both_v4_and_v6", GETDNS_EXTENSION_TRUE);
|
this_ret =
|
||||||
if (this_ret != GETDNS_RETURN_GOOD)
|
getdns_dict_set_int(this_extensions, "return_both_v4_and_v6",
|
||||||
{
|
GETDNS_EXTENSION_TRUE);
|
||||||
fprintf(stderr, "Trying to set an extension do both IPv4 and IPv6 failed: %d", this_ret);
|
if (this_ret != GETDNS_RETURN_GOOD) {
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
fprintf(stderr,
|
||||||
|
"Trying to set an extension do both IPv4 and IPv6 failed: %d",
|
||||||
|
this_ret);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make the call */
|
/* Make the call */
|
||||||
getdns_return_t dns_request_return = getdns_general_sync(this_context, this_name, this_request_type,
|
getdns_return_t dns_request_return =
|
||||||
this_extensions, &this_response_length, &this_response);
|
getdns_general_sync(this_context, this_name, this_request_type,
|
||||||
|
this_extensions, &this_response_length, &this_response);
|
||||||
/* free the extensions */
|
/* free the extensions */
|
||||||
getdns_dict_destroy(this_extensions);
|
getdns_dict_destroy(this_extensions);
|
||||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||||
{
|
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
||||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
|
this_name);
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Be sure the search returned something */
|
/* Be sure the search returned something */
|
||||||
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
||||||
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
||||||
{
|
{
|
||||||
fprintf(stderr, "The search had no results, and a return value of %d. Exiting.", this_error);
|
fprintf(stderr,
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
"The search had no results, and a return value of %d. Exiting.",
|
||||||
|
this_error);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr); // Ignore any error
|
this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr); // Ignore any error
|
||||||
this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
|
this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
|
||||||
/* Go through each record */
|
/* Go through each record */
|
||||||
if (num_addresses > 0) {
|
if (num_addresses > 0) {
|
||||||
for (rec_count = 0; rec_count < num_addresses; ++rec_count )
|
for (rec_count = 0; rec_count < num_addresses;
|
||||||
{
|
++rec_count) {
|
||||||
char * display;
|
char *display;
|
||||||
this_ret = getdns_list_get_bindata(just_the_addresses_ptr, rec_count, &this_address_data); // Ignore any error
|
this_ret = getdns_list_get_bindata(just_the_addresses_ptr, rec_count, &this_address_data); // Ignore any error
|
||||||
display = getdns_display_ip_address(this_address_data);
|
display =
|
||||||
/* Just print the address */
|
getdns_display_ip_address
|
||||||
printf("The address is %s\n", display);
|
(this_address_data);
|
||||||
if (display) {
|
/* Just print the address */
|
||||||
free(display);
|
printf("The address is %s\n", display);
|
||||||
}
|
if (display) {
|
||||||
}
|
free(display);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
|
@ -109,6 +115,6 @@ main()
|
||||||
getdns_free_sync_request_memory(this_response);
|
getdns_free_sync_request_memory(this_response);
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* example-synchronous.c */
|
/* example-synchronous.c */
|
||||||
|
|
|
@ -9,124 +9,143 @@
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
/* Set up the callback function, which will also do the processing of the results */
|
/* Set up the callback function, which will also do the processing of the results */
|
||||||
void this_callbackfn(struct getdns_context_t *this_context,
|
void
|
||||||
getdns_return_t this_callback_type,
|
this_callbackfn(struct getdns_context_t *this_context,
|
||||||
struct getdns_dict *this_response,
|
getdns_return_t this_callback_type,
|
||||||
void *this_userarg,
|
struct getdns_dict *this_response,
|
||||||
getdns_transaction_t this_transaction_id)
|
void *this_userarg, getdns_transaction_t this_transaction_id)
|
||||||
{
|
{
|
||||||
UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
|
UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
|
||||||
UNUSED_PARAM(this_context); /* Not looking at the context for this example */
|
UNUSED_PARAM(this_context); /* Not looking at the context for this example */
|
||||||
getdns_return_t this_ret; /* Holder for all function returns */
|
getdns_return_t this_ret; /* Holder for all function returns */
|
||||||
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
|
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */
|
||||||
{
|
|
||||||
/* Be sure the search returned something */
|
/* Be sure the search returned something */
|
||||||
uint32_t this_error;
|
uint32_t this_error;
|
||||||
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
|
||||||
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
|
||||||
{
|
{
|
||||||
fprintf(stderr, "The search had no results, and a return value of %d. Exiting.", this_error);
|
fprintf(stderr,
|
||||||
|
"The search had no results, and a return value of %d. Exiting.",
|
||||||
|
this_error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Find all the answers returned */
|
/* Find all the answers returned */
|
||||||
struct getdns_list * these_answers;
|
struct getdns_list *these_answers;
|
||||||
this_ret = getdns_dict_get_list(this_response, "replies_tree", &these_answers);
|
this_ret =
|
||||||
if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
|
getdns_dict_get_list(this_response, "replies_tree",
|
||||||
{
|
&these_answers);
|
||||||
fprintf(stderr, "Weird: the response had no error, but also no replies_tree. Exiting.");
|
if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Weird: the response had no error, but also no replies_tree. Exiting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t num_answers;
|
size_t num_answers;
|
||||||
this_ret = getdns_list_get_length(these_answers, &num_answers);
|
this_ret = getdns_list_get_length(these_answers, &num_answers);
|
||||||
/* Go through each answer */
|
/* Go through each answer */
|
||||||
for ( size_t rec_count = 0; rec_count < num_answers; ++rec_count )
|
for (size_t rec_count = 0; rec_count < num_answers;
|
||||||
{
|
++rec_count) {
|
||||||
struct getdns_dict * this_record;
|
struct getdns_dict *this_record;
|
||||||
this_ret = getdns_list_get_dict(these_answers, rec_count, &this_record); // Ignore any error
|
this_ret = getdns_list_get_dict(these_answers, rec_count, &this_record); // Ignore any error
|
||||||
/* Get the answer section */
|
/* Get the answer section */
|
||||||
struct getdns_list * this_answer;
|
struct getdns_list *this_answer;
|
||||||
this_ret = getdns_dict_get_list(this_record, "answer", &this_answer); // Ignore any error
|
this_ret = getdns_dict_get_list(this_record, "answer", &this_answer); // Ignore any error
|
||||||
/* Get each RR in the answer section */
|
/* Get each RR in the answer section */
|
||||||
size_t num_rrs_ptr;
|
size_t num_rrs_ptr;
|
||||||
this_ret = getdns_list_get_length(this_answer, &num_rrs_ptr);
|
this_ret =
|
||||||
for ( size_t rr_count = 0; rr_count < num_rrs_ptr; ++rr_count )
|
getdns_list_get_length(this_answer, &num_rrs_ptr);
|
||||||
{
|
for (size_t rr_count = 0; rr_count < num_rrs_ptr;
|
||||||
struct getdns_dict * this_rr = NULL;
|
++rr_count) {
|
||||||
this_ret = getdns_list_get_dict(this_answer, rr_count, &this_rr); // Ignore any error
|
struct getdns_dict *this_rr = NULL;
|
||||||
|
this_ret = getdns_list_get_dict(this_answer, rr_count, &this_rr); // Ignore any error
|
||||||
/* Get the RDATA */
|
/* Get the RDATA */
|
||||||
struct getdns_dict * this_rdata = NULL;
|
struct getdns_dict *this_rdata = NULL;
|
||||||
this_ret = getdns_dict_get_dict(this_rr, "rdata", &this_rdata); // Ignore any error
|
this_ret = getdns_dict_get_dict(this_rr, "rdata", &this_rdata); // Ignore any error
|
||||||
/* Get the RDATA type */
|
/* Get the RDATA type */
|
||||||
uint32_t this_type;
|
uint32_t this_type;
|
||||||
this_ret = getdns_dict_get_int(this_rr, "type", &this_type); // Ignore any error
|
this_ret = getdns_dict_get_int(this_rr, "type", &this_type); // Ignore any error
|
||||||
/* If it is type A or AAAA, print the value */
|
/* If it is type A or AAAA, print the value */
|
||||||
if (this_type == GETDNS_RRTYPE_A)
|
if (this_type == GETDNS_RRTYPE_A) {
|
||||||
{
|
struct getdns_bindata *this_a_record =
|
||||||
struct getdns_bindata * this_a_record = NULL;
|
NULL;
|
||||||
this_ret = getdns_dict_get_bindata(this_rdata, "ipv4_address", &this_a_record);
|
this_ret =
|
||||||
if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
|
getdns_dict_get_bindata(this_rdata,
|
||||||
{
|
"ipv4_address", &this_a_record);
|
||||||
fprintf(stderr, "Weird: the A record at %d in record at %d had no address. Exiting.",
|
if (this_ret ==
|
||||||
(int) rr_count, (int) rec_count);
|
GETDNS_RETURN_NO_SUCH_DICT_NAME) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Weird: the A record at %d in record at %d had no address. Exiting.",
|
||||||
|
(int) rr_count,
|
||||||
|
(int) rec_count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("The IPv4 address is %s\n", getdns_display_ip_address(this_a_record));
|
printf("The IPv4 address is %s\n",
|
||||||
}
|
getdns_display_ip_address
|
||||||
else if (this_type == GETDNS_RRTYPE_AAAA)
|
(this_a_record));
|
||||||
{
|
} else if (this_type == GETDNS_RRTYPE_AAAA) {
|
||||||
struct getdns_bindata * this_aaaa_record = NULL;
|
struct getdns_bindata *this_aaaa_record
|
||||||
this_ret = getdns_dict_get_bindata(this_rdata, "ipv6_address", &this_aaaa_record);
|
= NULL;
|
||||||
if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
|
this_ret =
|
||||||
{
|
getdns_dict_get_bindata(this_rdata,
|
||||||
fprintf(stderr, "Weird: the AAAA record at %d in record at %d had no address. Exiting.",
|
"ipv6_address", &this_aaaa_record);
|
||||||
(int) rr_count, (int) rec_count);
|
if (this_ret ==
|
||||||
|
GETDNS_RETURN_NO_SUCH_DICT_NAME) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Weird: the AAAA record at %d in record at %d had no address. Exiting.",
|
||||||
|
(int) rr_count,
|
||||||
|
(int) rec_count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("The IPv6 address is %s\n", getdns_display_ip_address(this_aaaa_record));
|
printf("The IPv6 address is %s\n",
|
||||||
|
getdns_display_ip_address
|
||||||
|
(this_aaaa_record));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
||||||
else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
fprintf(stderr,
|
||||||
fprintf(stderr, "The callback with ID %"PRIu64" was cancelled. Exiting.", this_transaction_id);
|
"The callback with ID %" PRIu64 " was cancelled. Exiting.",
|
||||||
|
this_transaction_id);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "The callback got a callback_type of %d. Exiting.", this_callback_type);
|
fprintf(stderr,
|
||||||
|
"The callback got a callback_type of %d. Exiting.",
|
||||||
|
this_callback_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
/* Create the DNS context for this call */
|
/* Create the DNS context for this call */
|
||||||
struct getdns_context_t *this_context = NULL;
|
struct getdns_context_t *this_context = NULL;
|
||||||
getdns_return_t context_create_return = getdns_context_create(&this_context, true);
|
getdns_return_t context_create_return =
|
||||||
if (context_create_return != GETDNS_RETURN_GOOD)
|
getdns_context_create(&this_context, true);
|
||||||
{
|
if (context_create_return != GETDNS_RETURN_GOOD) {
|
||||||
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
|
fprintf(stderr, "Trying to create the context failed: %d",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
context_create_return);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
/* Create an event base and put it in the context using the unknown function name */
|
/* Create an event base and put it in the context using the unknown function name */
|
||||||
struct event_base *this_event_base;
|
struct event_base *this_event_base;
|
||||||
this_event_base = event_base_new();
|
this_event_base = event_base_new();
|
||||||
if (this_event_base == NULL)
|
if (this_event_base == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Trying to create the event base failed.");
|
fprintf(stderr, "Trying to create the event base failed.");
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
(void)getdns_extension_set_libevent_base(this_context, this_event_base);
|
(void) getdns_extension_set_libevent_base(this_context,
|
||||||
|
this_event_base);
|
||||||
/* Set up the getdns call */
|
/* Set up the getdns call */
|
||||||
const char * this_name = "www.example.com";
|
const char *this_name = "www.example.com";
|
||||||
char* this_userarg = "somestring"; // Could add things here to help identify this call
|
char *this_userarg = "somestring"; // Could add things here to help identify this call
|
||||||
getdns_transaction_t this_transaction_id = 0;
|
getdns_transaction_t this_transaction_id = 0;
|
||||||
|
|
||||||
/* Make the call */
|
/* Make the call */
|
||||||
getdns_return_t dns_request_return = getdns_address(this_context, this_name,
|
getdns_return_t dns_request_return =
|
||||||
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
getdns_address(this_context, this_name,
|
||||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
||||||
{
|
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
|
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
this_name);
|
||||||
}
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
/* Call the event loop */
|
/* Call the event loop */
|
||||||
int dispatch_return = event_base_dispatch(this_event_base);
|
int dispatch_return = event_base_dispatch(this_event_base);
|
||||||
UNUSED_PARAM(dispatch_return);
|
UNUSED_PARAM(dispatch_return);
|
||||||
|
|
499
src/general.c
499
src/general.c
|
@ -48,316 +48,311 @@
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
/* declarations */
|
/* declarations */
|
||||||
static void ub_resolve_callback(void* arg, int err, ldns_buffer* result, int sec, char* bogus);
|
static void ub_resolve_callback(void *arg, int err, ldns_buffer * result,
|
||||||
|
int sec, char *bogus);
|
||||||
static void ub_resolve_timeout(evutil_socket_t fd, short what, void *arg);
|
static void ub_resolve_timeout(evutil_socket_t fd, short what, void *arg);
|
||||||
static void ub_local_resolve_timeout(evutil_socket_t fd, short what, void *arg);
|
static void ub_local_resolve_timeout(evutil_socket_t fd, short what,
|
||||||
|
void *arg);
|
||||||
|
|
||||||
static void handle_network_request_error(getdns_network_req* netreq, int err);
|
static void handle_network_request_error(getdns_network_req * netreq, int err);
|
||||||
static void handle_dns_request_complete(getdns_dns_req* dns_req);
|
static void handle_dns_request_complete(getdns_dns_req * dns_req);
|
||||||
static int submit_network_request(getdns_network_req* netreq);
|
static int submit_network_request(getdns_network_req * netreq);
|
||||||
|
|
||||||
typedef struct netreq_cb_data {
|
typedef struct netreq_cb_data
|
||||||
getdns_network_req *netreq;
|
{
|
||||||
int err;
|
getdns_network_req *netreq;
|
||||||
ldns_buffer* result;
|
int err;
|
||||||
int sec;
|
ldns_buffer *result;
|
||||||
char* bogus;
|
int sec;
|
||||||
|
char *bogus;
|
||||||
} netreq_cb_data;
|
} netreq_cb_data;
|
||||||
|
|
||||||
/* cancel, cleanup and send timeout to callback */
|
/* cancel, cleanup and send timeout to callback */
|
||||||
static void ub_resolve_timeout(evutil_socket_t fd, short what, void *arg) {
|
static void
|
||||||
getdns_dns_req *dns_req = (getdns_dns_req*) arg;
|
ub_resolve_timeout(evutil_socket_t fd, short what, void *arg)
|
||||||
getdns_context_t context = dns_req->context;
|
{
|
||||||
getdns_transaction_t trans_id = dns_req->trans_id;
|
getdns_dns_req *dns_req = (getdns_dns_req *) arg;
|
||||||
getdns_callback_t cb = dns_req->user_callback;
|
getdns_context_t context = dns_req->context;
|
||||||
void* user_arg = dns_req->user_pointer;
|
getdns_transaction_t trans_id = dns_req->trans_id;
|
||||||
|
getdns_callback_t cb = dns_req->user_callback;
|
||||||
|
void *user_arg = dns_req->user_pointer;
|
||||||
|
|
||||||
/* cancel the req - also clears it from outbound */
|
/* cancel the req - also clears it from outbound */
|
||||||
getdns_context_cancel_request(context, trans_id, 0);
|
getdns_context_cancel_request(context, trans_id, 0);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
dns_req_free(dns_req);
|
dns_req_free(dns_req);
|
||||||
|
|
||||||
cb(context,
|
cb(context, GETDNS_CALLBACK_TIMEOUT, NULL, user_arg, trans_id);
|
||||||
GETDNS_CALLBACK_TIMEOUT,
|
|
||||||
NULL,
|
|
||||||
user_arg,
|
|
||||||
trans_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ub_local_resolve_timeout(evutil_socket_t fd, short what, void *arg) {
|
static void
|
||||||
netreq_cb_data* cb_data = (netreq_cb_data*) arg;
|
ub_local_resolve_timeout(evutil_socket_t fd, short what, void *arg)
|
||||||
|
{
|
||||||
/* cleanup the local timer here since the memory may be
|
netreq_cb_data *cb_data = (netreq_cb_data *) arg;
|
||||||
* invalid after calling ub_resolve_callback
|
|
||||||
*/
|
|
||||||
getdns_dns_req* dnsreq = cb_data->netreq->owner;
|
|
||||||
event_free(dnsreq->local_cb_timer);
|
|
||||||
dnsreq->local_cb_timer = NULL;
|
|
||||||
|
|
||||||
/* just call ub_resolve_callback */
|
/* cleanup the local timer here since the memory may be
|
||||||
ub_resolve_callback(cb_data->netreq, cb_data->err, cb_data->result, cb_data->sec, cb_data->bogus);
|
* invalid after calling ub_resolve_callback
|
||||||
|
*/
|
||||||
|
getdns_dns_req *dnsreq = cb_data->netreq->owner;
|
||||||
|
event_free(dnsreq->local_cb_timer);
|
||||||
|
dnsreq->local_cb_timer = NULL;
|
||||||
|
|
||||||
/* cleanup the state */
|
/* just call ub_resolve_callback */
|
||||||
ldns_buffer_free(cb_data->result);
|
ub_resolve_callback(cb_data->netreq, cb_data->err, cb_data->result,
|
||||||
if (cb_data->bogus) {
|
cb_data->sec, cb_data->bogus);
|
||||||
free(cb_data->bogus);
|
|
||||||
}
|
/* cleanup the state */
|
||||||
free(cb_data);
|
ldns_buffer_free(cb_data->result);
|
||||||
|
if (cb_data->bogus) {
|
||||||
|
free(cb_data->bogus);
|
||||||
|
}
|
||||||
|
free(cb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup and send an error to the user callback */
|
/* cleanup and send an error to the user callback */
|
||||||
static void handle_network_request_error(getdns_network_req* netreq, int err) {
|
static void
|
||||||
getdns_dns_req *dns_req = netreq->owner;
|
handle_network_request_error(getdns_network_req * netreq, int err)
|
||||||
getdns_context_t context = dns_req->context;
|
{
|
||||||
getdns_transaction_t trans_id = dns_req->trans_id;
|
getdns_dns_req *dns_req = netreq->owner;
|
||||||
getdns_callback_t cb = dns_req->user_callback;
|
getdns_context_t context = dns_req->context;
|
||||||
void* user_arg = dns_req->user_pointer;
|
getdns_transaction_t trans_id = dns_req->trans_id;
|
||||||
|
getdns_callback_t cb = dns_req->user_callback;
|
||||||
|
void *user_arg = dns_req->user_pointer;
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
getdns_context_clear_outbound_request(dns_req);
|
getdns_context_clear_outbound_request(dns_req);
|
||||||
dns_req_free(dns_req);
|
dns_req_free(dns_req);
|
||||||
|
|
||||||
cb(context,
|
cb(context, GETDNS_CALLBACK_ERROR, NULL, user_arg, trans_id);
|
||||||
GETDNS_CALLBACK_ERROR,
|
|
||||||
NULL,
|
|
||||||
user_arg,
|
|
||||||
trans_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup and send the response to the user callback */
|
/* cleanup and send the response to the user callback */
|
||||||
static void handle_dns_request_complete(getdns_dns_req* dns_req) {
|
static void
|
||||||
getdns_dict* response = create_getdns_response(dns_req);
|
handle_dns_request_complete(getdns_dns_req * dns_req)
|
||||||
|
{
|
||||||
|
getdns_dict *response = create_getdns_response(dns_req);
|
||||||
|
|
||||||
getdns_context_t context = dns_req->context;
|
getdns_context_t context = dns_req->context;
|
||||||
getdns_transaction_t trans_id = dns_req->trans_id;
|
getdns_transaction_t trans_id = dns_req->trans_id;
|
||||||
getdns_callback_t cb = dns_req->user_callback;
|
getdns_callback_t cb = dns_req->user_callback;
|
||||||
void* user_arg = dns_req->user_pointer;
|
void *user_arg = dns_req->user_pointer;
|
||||||
|
|
||||||
/* clean up the request */
|
/* clean up the request */
|
||||||
getdns_context_clear_outbound_request(dns_req);
|
getdns_context_clear_outbound_request(dns_req);
|
||||||
dns_req_free(dns_req);
|
dns_req_free(dns_req);
|
||||||
if (response) {
|
if (response) {
|
||||||
cb(context,
|
cb(context,
|
||||||
GETDNS_CALLBACK_COMPLETE,
|
GETDNS_CALLBACK_COMPLETE, response, user_arg, trans_id);
|
||||||
response,
|
} else {
|
||||||
user_arg,
|
cb(context, GETDNS_CALLBACK_ERROR, NULL, user_arg, trans_id);
|
||||||
trans_id);
|
}
|
||||||
} else {
|
|
||||||
cb(context,
|
|
||||||
GETDNS_CALLBACK_ERROR,
|
|
||||||
NULL,
|
|
||||||
user_arg,
|
|
||||||
trans_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int submit_network_request(getdns_network_req* netreq) {
|
static int
|
||||||
getdns_dns_req *dns_req = netreq->owner;
|
submit_network_request(getdns_network_req * netreq)
|
||||||
int r = ub_resolve_event(dns_req->unbound,
|
{
|
||||||
dns_req->name,
|
getdns_dns_req *dns_req = netreq->owner;
|
||||||
netreq->request_type,
|
int r = ub_resolve_event(dns_req->unbound,
|
||||||
netreq->request_class,
|
dns_req->name,
|
||||||
netreq,
|
netreq->request_type,
|
||||||
ub_resolve_callback,
|
netreq->request_class,
|
||||||
&(netreq->unbound_id));
|
netreq,
|
||||||
netreq->state = NET_REQ_IN_FLIGHT;
|
ub_resolve_callback,
|
||||||
return r;
|
&(netreq->unbound_id));
|
||||||
|
netreq->state = NET_REQ_IN_FLIGHT;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ub_resolve_callback(void *arg, int err, ldns_buffer * result, int sec,
|
||||||
|
char *bogus)
|
||||||
|
{
|
||||||
|
getdns_network_req *netreq = (getdns_network_req *) arg;
|
||||||
|
/* if netreq->state == NET_REQ_NOT_SENT here, that implies
|
||||||
|
* that ub called us back immediately - probably from a local file.
|
||||||
|
* This most likely means that getdns_general has not returned
|
||||||
|
*/
|
||||||
|
if (netreq->state == NET_REQ_NOT_SENT) {
|
||||||
|
/* just do a very short timer since this was called immediately.
|
||||||
|
* we can make this less hacky, but it gets interesting when multiple
|
||||||
|
* netreqs need to be issued and some resolve immediately vs. not.
|
||||||
|
*/
|
||||||
|
struct timeval tv;
|
||||||
|
getdns_dns_req *dnsreq = netreq->owner;
|
||||||
|
netreq_cb_data *cb_data =
|
||||||
|
(netreq_cb_data *) malloc(sizeof(netreq_cb_data));
|
||||||
|
|
||||||
|
cb_data->netreq = netreq;
|
||||||
static void ub_resolve_callback(void* arg, int err, ldns_buffer* result, int sec, char* bogus) {
|
cb_data->err = err;
|
||||||
getdns_network_req* netreq = (getdns_network_req*) arg;
|
cb_data->sec = sec;
|
||||||
/* if netreq->state == NET_REQ_NOT_SENT here, that implies
|
cb_data->result = NULL;
|
||||||
* that ub called us back immediately - probably from a local file.
|
cb_data->bogus = NULL; /* unused but here in case we need it */
|
||||||
* This most likely means that getdns_general has not returned
|
if (result) {
|
||||||
*/
|
cb_data->result =
|
||||||
if (netreq->state == NET_REQ_NOT_SENT) {
|
ldns_buffer_new(ldns_buffer_limit(result));
|
||||||
/* just do a very short timer since this was called immediately.
|
if (!cb_data->result) {
|
||||||
* we can make this less hacky, but it gets interesting when multiple
|
cb_data->err = GETDNS_RETURN_GENERIC_ERROR;
|
||||||
* netreqs need to be issued and some resolve immediately vs. not.
|
} else {
|
||||||
*/
|
/* copy */
|
||||||
struct timeval tv;
|
ldns_buffer_copy(cb_data->result, result);
|
||||||
getdns_dns_req* dnsreq = netreq->owner;
|
}
|
||||||
netreq_cb_data* cb_data = (netreq_cb_data*) malloc(sizeof(netreq_cb_data));
|
}
|
||||||
|
/* schedule the timeout */
|
||||||
cb_data->netreq = netreq;
|
dnsreq->local_cb_timer =
|
||||||
cb_data->err = err;
|
evtimer_new(dnsreq->ev_base, ub_local_resolve_timeout,
|
||||||
cb_data->sec = sec;
|
cb_data);
|
||||||
cb_data->result = NULL;
|
tv.tv_sec = 0;
|
||||||
cb_data->bogus = NULL; /* unused but here in case we need it */
|
/* half ms */
|
||||||
if (result) {
|
tv.tv_usec = 500;
|
||||||
cb_data->result = ldns_buffer_new(ldns_buffer_limit(result));
|
evtimer_add(dnsreq->local_cb_timer, &tv);
|
||||||
if (!cb_data->result) {
|
return;
|
||||||
cb_data->err = GETDNS_RETURN_GENERIC_ERROR;
|
}
|
||||||
} else {
|
netreq->state = NET_REQ_FINISHED;
|
||||||
/* copy */
|
if (err) {
|
||||||
ldns_buffer_copy(cb_data->result, result);
|
handle_network_request_error(netreq, err);
|
||||||
}
|
} else {
|
||||||
}
|
/* parse */
|
||||||
/* schedule the timeout */
|
ldns_status r =
|
||||||
dnsreq->local_cb_timer = evtimer_new(dnsreq->ev_base, ub_local_resolve_timeout, cb_data);
|
ldns_buffer2pkt_wire(&(netreq->result), result);
|
||||||
tv.tv_sec = 0;
|
if (r != LDNS_STATUS_OK) {
|
||||||
/* half ms */
|
handle_network_request_error(netreq, r);
|
||||||
tv.tv_usec = 500;
|
} else {
|
||||||
evtimer_add(dnsreq->local_cb_timer, &tv);
|
/* is this the last request */
|
||||||
return;
|
if (!netreq->next) {
|
||||||
}
|
/* finished */
|
||||||
netreq->state = NET_REQ_FINISHED;
|
handle_dns_request_complete(netreq->owner);
|
||||||
if (err) {
|
} else {
|
||||||
handle_network_request_error(netreq, err);
|
/* not finished - update to next request and ship it */
|
||||||
} else {
|
getdns_dns_req *dns_req = netreq->owner;
|
||||||
/* parse */
|
dns_req->current_req = netreq->next;
|
||||||
ldns_status r = ldns_buffer2pkt_wire(&(netreq->result), result);
|
submit_network_request(netreq->next);
|
||||||
if (r != LDNS_STATUS_OK) {
|
}
|
||||||
handle_network_request_error(netreq, r);
|
}
|
||||||
} else {
|
}
|
||||||
/* is this the last request */
|
|
||||||
if (!netreq->next) {
|
|
||||||
/* finished */
|
|
||||||
handle_dns_request_complete(netreq->owner);
|
|
||||||
} else {
|
|
||||||
/* not finished - update to next request and ship it */
|
|
||||||
getdns_dns_req* dns_req = netreq->owner;
|
|
||||||
dns_req->current_req = netreq->next;
|
|
||||||
submit_network_request(netreq->next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general_ub(struct ub_ctx* unbound,
|
getdns_general_ub(struct ub_ctx *unbound,
|
||||||
struct event_base* ev_base,
|
struct event_base *ev_base,
|
||||||
getdns_context_t context,
|
getdns_context_t context,
|
||||||
const char *name,
|
const char *name,
|
||||||
uint16_t request_type,
|
uint16_t request_type,
|
||||||
struct getdns_dict *extensions,
|
struct getdns_dict *extensions,
|
||||||
void *userarg,
|
void *userarg,
|
||||||
getdns_transaction_t *transaction_id,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn)
|
||||||
getdns_callback_t callbackfn)
|
|
||||||
{
|
{
|
||||||
/* timeout */
|
/* timeout */
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
getdns_return_t gr;
|
getdns_return_t gr;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
gr = getdns_context_prepare_for_resolution(context);
|
gr = getdns_context_prepare_for_resolution(context);
|
||||||
if (gr != GETDNS_RETURN_GOOD) {
|
if (gr != GETDNS_RETURN_GOOD) {
|
||||||
return GETDNS_RETURN_BAD_CONTEXT;
|
return GETDNS_RETURN_BAD_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* request state */
|
/* request state */
|
||||||
getdns_dns_req* req = dns_req_new(context,
|
getdns_dns_req *req = dns_req_new(context,
|
||||||
unbound,
|
unbound,
|
||||||
name,
|
name,
|
||||||
request_type,
|
request_type,
|
||||||
extensions);
|
extensions);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->user_pointer = userarg;
|
req->user_pointer = userarg;
|
||||||
req->user_callback = callbackfn;
|
req->user_callback = callbackfn;
|
||||||
|
|
||||||
if (transaction_id) {
|
if (transaction_id) {
|
||||||
*transaction_id = req->trans_id;
|
*transaction_id = req->trans_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_context_track_outbound_request(req);
|
getdns_context_track_outbound_request(req);
|
||||||
|
|
||||||
/* assign a timeout */
|
/* assign a timeout */
|
||||||
req->ev_base = ev_base;
|
req->ev_base = ev_base;
|
||||||
req->timeout = evtimer_new(ev_base, ub_resolve_timeout, req);
|
req->timeout = evtimer_new(ev_base, ub_resolve_timeout, req);
|
||||||
tv.tv_sec = context->timeout / 1000;
|
tv.tv_sec = context->timeout / 1000;
|
||||||
tv.tv_usec = (context->timeout % 1000) * 1000;
|
tv.tv_usec = (context->timeout % 1000) * 1000;
|
||||||
evtimer_add(req->timeout, &tv);
|
evtimer_add(req->timeout, &tv);
|
||||||
|
|
||||||
/* issue the first network req */
|
/* issue the first network req */
|
||||||
|
|
||||||
r = submit_network_request(req->first_req);
|
r = submit_network_request(req->first_req);
|
||||||
|
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
/* clean up the request */
|
/* clean up the request */
|
||||||
getdns_context_clear_outbound_request(req);
|
getdns_context_clear_outbound_request(req);
|
||||||
dns_req_free(req);
|
dns_req_free(req);
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
} /* getdns_general_ub */
|
} /* getdns_general_ub */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getdns_general
|
* getdns_general
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general(getdns_context_t context,
|
getdns_general(getdns_context_t context,
|
||||||
const char *name,
|
const char *name,
|
||||||
uint16_t request_type,
|
uint16_t request_type,
|
||||||
struct getdns_dict *extensions,
|
struct getdns_dict * extensions,
|
||||||
void *userarg,
|
void *userarg,
|
||||||
getdns_transaction_t *transaction_id,
|
getdns_transaction_t * transaction_id, getdns_callback_t callback)
|
||||||
getdns_callback_t callback)
|
|
||||||
{
|
{
|
||||||
int extcheck = GETDNS_RETURN_GOOD;
|
int extcheck = GETDNS_RETURN_GOOD;
|
||||||
|
|
||||||
if (!context || !context->event_base_async ||
|
if (!context || !context->event_base_async || callback == NULL) {
|
||||||
callback == NULL) {
|
/* Can't do async without an event loop
|
||||||
/* Can't do async without an event loop
|
* or callback
|
||||||
* or callback
|
*/
|
||||||
*/
|
return GETDNS_RETURN_BAD_CONTEXT;
|
||||||
return GETDNS_RETURN_BAD_CONTEXT;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
extcheck = validate_extensions(extensions);
|
extcheck = validate_extensions(extensions);
|
||||||
if(extcheck != GETDNS_RETURN_GOOD)
|
if (extcheck != GETDNS_RETURN_GOOD)
|
||||||
return extcheck;
|
return extcheck;
|
||||||
|
|
||||||
return getdns_general_ub(context->unbound_async,
|
return getdns_general_ub(context->unbound_async,
|
||||||
context->event_base_async,
|
context->event_base_async,
|
||||||
context,
|
context,
|
||||||
name,
|
name, request_type, extensions, userarg, transaction_id, callback);
|
||||||
request_type,
|
|
||||||
extensions,
|
|
||||||
userarg,
|
|
||||||
transaction_id,
|
|
||||||
callback);
|
|
||||||
|
|
||||||
} /* getdns_general */
|
} /* getdns_general */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getdns_address
|
* getdns_address
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_address(getdns_context_t context,
|
getdns_address(getdns_context_t context,
|
||||||
const char *name,
|
const char *name,
|
||||||
struct getdns_dict *extensions,
|
struct getdns_dict * extensions,
|
||||||
void *userarg,
|
void *userarg,
|
||||||
getdns_transaction_t *transaction_id,
|
getdns_transaction_t * transaction_id, getdns_callback_t callback)
|
||||||
getdns_callback_t callback) {
|
{
|
||||||
int cleanup_extensions = 0;
|
int cleanup_extensions = 0;
|
||||||
if (!extensions) {
|
if (!extensions) {
|
||||||
extensions = getdns_dict_create();
|
extensions = getdns_dict_create();
|
||||||
cleanup_extensions = 1;
|
cleanup_extensions = 1;
|
||||||
}
|
}
|
||||||
getdns_dict_set_int(extensions,
|
getdns_dict_set_int(extensions,
|
||||||
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6,
|
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, GETDNS_EXTENSION_TRUE);
|
||||||
GETDNS_EXTENSION_TRUE);
|
|
||||||
|
|
||||||
getdns_return_t result =
|
getdns_return_t result = getdns_general(context, name, GETDNS_RRTYPE_A,
|
||||||
getdns_general(context, name, GETDNS_RRTYPE_A,
|
extensions, userarg, transaction_id,
|
||||||
extensions, userarg, transaction_id,
|
callback);
|
||||||
callback);
|
if (cleanup_extensions) {
|
||||||
if (cleanup_extensions) {
|
getdns_dict_destroy(extensions);
|
||||||
getdns_dict_destroy(extensions);
|
}
|
||||||
}
|
return result;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getdns_general.c */
|
/* getdns_general.c */
|
||||||
|
|
|
@ -44,16 +44,13 @@ struct ub_ctx;
|
||||||
struct event_base;
|
struct event_base;
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general_ub(
|
getdns_general_ub(struct ub_ctx *unbound,
|
||||||
struct ub_ctx* unbound,
|
struct event_base *ev_base,
|
||||||
struct event_base* ev_base,
|
getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
uint16_t request_type,
|
||||||
uint16_t request_type,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callbackfn
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,7 +74,6 @@ struct event_base;
|
||||||
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED 309
|
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED 309
|
||||||
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT A query was made with a context that is using stub resolution and a DNSSEC extension specified.
|
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT A query was made with a context that is using stub resolution and a DNSSEC extension specified.
|
||||||
|
|
||||||
|
|
||||||
/** @}
|
/** @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -370,17 +369,19 @@ struct event_base;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct getdns_context_t *getdns_context_t;
|
typedef struct getdns_context_t *getdns_context_t;
|
||||||
typedef uint16_t getdns_return_t;
|
typedef uint16_t getdns_return_t;
|
||||||
typedef uint64_t getdns_transaction_t;
|
typedef uint64_t getdns_transaction_t;
|
||||||
/**
|
/**
|
||||||
* used to check data types within complex types (dict, list)
|
* used to check data types within complex types (dict, list)
|
||||||
*/
|
*/
|
||||||
typedef enum getdns_data_type {
|
typedef enum getdns_data_type
|
||||||
t_dict, t_list, t_int, t_bindata, t_invalid
|
{
|
||||||
|
t_dict, t_list, t_int, t_bindata, t_invalid
|
||||||
} getdns_data_type;
|
} getdns_data_type;
|
||||||
typedef struct getdns_bindata {
|
typedef struct getdns_bindata
|
||||||
size_t size;
|
{
|
||||||
uint8_t *data;
|
size_t size;
|
||||||
|
uint8_t *data;
|
||||||
} getdns_bindata;
|
} getdns_bindata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,7 +400,6 @@ typedef struct getdns_dict getdns_dict;
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
|
getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getdns list data type
|
* getdns list data type
|
||||||
* Use helper functions getdns_list_* to manipulate and iterate lists
|
* Use helper functions getdns_list_* to manipulate and iterate lists
|
||||||
|
@ -414,7 +414,8 @@ typedef struct getdns_list getdns_list;
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is not valid or params are NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is not valid or params are NULL
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_length(struct getdns_list *list, size_t *answer);
|
getdns_return_t getdns_list_get_length(struct getdns_list *list,
|
||||||
|
size_t * answer);
|
||||||
/**
|
/**
|
||||||
* private function (API users should not be calling this), this uses library
|
* private function (API users should not be calling this), this uses library
|
||||||
* routines to make a copy of the list - would be faster to make the copy directly
|
* routines to make a copy of the list - would be faster to make the copy directly
|
||||||
|
@ -426,7 +427,8 @@ getdns_return_t getdns_list_get_length(struct getdns_list *list, size_t *answer)
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is invalid
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is invalid
|
||||||
* @return GETDNS_RETURN_GENERIC_ERROR if out of memory
|
* @return GETDNS_RETURN_GENERIC_ERROR if out of memory
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_copy(struct getdns_list *srclist, struct getdns_list **dstlist);
|
getdns_return_t getdns_list_copy(struct getdns_list *srclist,
|
||||||
|
struct getdns_list **dstlist);
|
||||||
/**
|
/**
|
||||||
* get the enumerated data type of the indexed list item
|
* get the enumerated data type of the indexed list item
|
||||||
* @param list the list from which to fetch the data type
|
* @param list the list from which to fetch the data type
|
||||||
|
@ -435,7 +437,8 @@ getdns_return_t getdns_list_copy(struct getdns_list *srclist, struct getdns_list
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_data_type(struct getdns_list *list, size_t index, getdns_data_type *answer);
|
getdns_return_t getdns_list_get_data_type(struct getdns_list *list,
|
||||||
|
size_t index, getdns_data_type * answer);
|
||||||
/**
|
/**
|
||||||
* retrieve the dictionary value of the specified list item, the caller must not free
|
* retrieve the dictionary value of the specified list item, the caller must not free
|
||||||
* storage associated with the return value. When the list is destroyed this
|
* storage associated with the return value. When the list is destroyed this
|
||||||
|
@ -447,7 +450,8 @@ getdns_return_t getdns_list_get_data_type(struct getdns_list *list, size_t index
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
||||||
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_dict(struct getdns_list *list, size_t index, struct getdns_dict **answer);
|
getdns_return_t getdns_list_get_dict(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_dict **answer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve the list value of the specified list item, the caller must not free
|
* retrieve the list value of the specified list item, the caller must not free
|
||||||
|
@ -460,7 +464,8 @@ getdns_return_t getdns_list_get_dict(struct getdns_list *list, size_t index, str
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
||||||
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_list(struct getdns_list *list, size_t index, struct getdns_list **answer);
|
getdns_return_t getdns_list_get_list(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_list **answer);
|
||||||
/**
|
/**
|
||||||
* retrieve the binary data value of the specified list item, the caller must not
|
* retrieve the binary data value of the specified list item, the caller must not
|
||||||
* free storage associated with the return value. When the list is destroyed any
|
* free storage associated with the return value. When the list is destroyed any
|
||||||
|
@ -472,7 +477,8 @@ getdns_return_t getdns_list_get_list(struct getdns_list *list, size_t index, str
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
||||||
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_bindata(struct getdns_list *list, size_t index, struct getdns_bindata **answer);
|
getdns_return_t getdns_list_get_bindata(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_bindata **answer);
|
||||||
/**
|
/**
|
||||||
* retrieve the integer value of the specified list item
|
* retrieve the integer value of the specified list item
|
||||||
* @param list the list from which to fetch the item
|
* @param list the list from which to fetch the item
|
||||||
|
@ -482,7 +488,8 @@ getdns_return_t getdns_list_get_bindata(struct getdns_list *list, size_t index,
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
|
||||||
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_get_int(struct getdns_list *list, size_t index, uint32_t *answer);
|
getdns_return_t getdns_list_get_int(struct getdns_list *list, size_t index,
|
||||||
|
uint32_t * answer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a list of names from the dictionary, this list must be freed by the caller
|
* fetch a list of names from the dictionary, this list must be freed by the caller
|
||||||
|
@ -492,7 +499,8 @@ getdns_return_t getdns_list_get_int(struct getdns_list *list, size_t index, uint
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or empty
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or empty
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_names(struct getdns_dict *dict, struct getdns_list **answer);
|
getdns_return_t getdns_dict_get_names(struct getdns_dict *dict,
|
||||||
|
struct getdns_list **answer);
|
||||||
/**
|
/**
|
||||||
* fetch the data type for the data associated with the specified name
|
* fetch the data type for the data associated with the specified name
|
||||||
* @param this_dict dictionary from which to fetch the data type
|
* @param this_dict dictionary from which to fetch the data type
|
||||||
|
@ -501,7 +509,8 @@ getdns_return_t getdns_dict_get_names(struct getdns_dict *dict, struct getdns_li
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_data_type(struct getdns_dict *this_dict, char *name, getdns_data_type *answer);
|
getdns_return_t getdns_dict_get_data_type(struct getdns_dict *this_dict,
|
||||||
|
char *name, getdns_data_type * answer);
|
||||||
/**
|
/**
|
||||||
* fetch the dictionary associated with the specified name, the dictionary should
|
* fetch the dictionary associated with the specified name, the dictionary should
|
||||||
* not be free()'d by the caller, it will be freed when the parent dictionary is
|
* not be free()'d by the caller, it will be freed when the parent dictionary is
|
||||||
|
@ -512,7 +521,8 @@ getdns_return_t getdns_dict_get_data_type(struct getdns_dict *this_dict, char *n
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_dict(struct getdns_dict *this_dict, char *name, struct getdns_dict **answer);
|
getdns_return_t getdns_dict_get_dict(struct getdns_dict *this_dict, char *name,
|
||||||
|
struct getdns_dict **answer);
|
||||||
/**
|
/**
|
||||||
* fetch the list associated with the specified name
|
* fetch the list associated with the specified name
|
||||||
* the list should not be free()'d by the caller, when the dictionary is destroyed
|
* the list should not be free()'d by the caller, when the dictionary is destroyed
|
||||||
|
@ -523,7 +533,8 @@ getdns_return_t getdns_dict_get_dict(struct getdns_dict *this_dict, char *name,
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_list(struct getdns_dict *this_dict, char *name, struct getdns_list **answer);
|
getdns_return_t getdns_dict_get_list(struct getdns_dict *this_dict, char *name,
|
||||||
|
struct getdns_list **answer);
|
||||||
/**
|
/**
|
||||||
* fetch the bindata associated with the specified name, the bindata should not be
|
* fetch the bindata associated with the specified name, the bindata should not be
|
||||||
* free()'d by the caller
|
* free()'d by the caller
|
||||||
|
@ -533,7 +544,8 @@ getdns_return_t getdns_dict_get_list(struct getdns_dict *this_dict, char *name,
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_bindata(struct getdns_dict *this_dict, char *name, struct getdns_bindata **answer);
|
getdns_return_t getdns_dict_get_bindata(struct getdns_dict *this_dict,
|
||||||
|
char *name, struct getdns_bindata **answer);
|
||||||
/**
|
/**
|
||||||
* fetch the integer value associated with the specified name
|
* fetch the integer value associated with the specified name
|
||||||
* @param this_dict dictionary from which to fetch the integer
|
* @param this_dict dictionary from which to fetch the integer
|
||||||
|
@ -542,13 +554,14 @@ getdns_return_t getdns_dict_get_bindata(struct getdns_dict *this_dict, char *nam
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_get_int(struct getdns_dict *this_dict, char *name, uint32_t *answer);
|
getdns_return_t getdns_dict_get_int(struct getdns_dict *this_dict, char *name,
|
||||||
|
uint32_t * answer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new list with no items
|
* create a new list with no items
|
||||||
* @return pointer to an allocated list, NULL if insufficient memory
|
* @return pointer to an allocated list, NULL if insufficient memory
|
||||||
*/
|
*/
|
||||||
struct getdns_list * getdns_list_create();
|
struct getdns_list *getdns_list_create();
|
||||||
/**
|
/**
|
||||||
* free memory allocated to the list (also frees all children of the list)
|
* free memory allocated to the list (also frees all children of the list)
|
||||||
* note that lists and bindata retrieved from the list via the getdns_list_get_*
|
* note that lists and bindata retrieved from the list via the getdns_list_get_*
|
||||||
|
@ -566,8 +579,9 @@ void getdns_list_destroy(struct getdns_list *list);
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_GENERAL_ERROR if out of memory
|
* @return GETDNS_RETURN_GENERAL_ERROR if out of memory
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t *index);
|
getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t * index);
|
||||||
getdns_return_t getdns_list_set_dict(struct getdns_list *list, size_t index, struct getdns_dict *child_dict);
|
getdns_return_t getdns_list_set_dict(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_dict *child_dict);
|
||||||
/**
|
/**
|
||||||
* assign the child_list to an item in a parent list, the parent list copies
|
* assign the child_list to an item in a parent list, the parent list copies
|
||||||
* the child list and will free the copy when the list is destroyed
|
* the child list and will free the copy when the list is destroyed
|
||||||
|
@ -577,7 +591,8 @@ getdns_return_t getdns_list_set_dict(struct getdns_list *list, size_t index, str
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_set_list(struct getdns_list *list, size_t index, struct getdns_list *child_list);
|
getdns_return_t getdns_list_set_list(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_list *child_list);
|
||||||
/**
|
/**
|
||||||
* assign the child_bindata to an item in a parent list, the parent list copies
|
* assign the child_bindata to an item in a parent list, the parent list copies
|
||||||
* the child data and will free the copy when the list is destroyed
|
* the child data and will free the copy when the list is destroyed
|
||||||
|
@ -587,13 +602,15 @@ getdns_return_t getdns_list_set_list(struct getdns_list *list, size_t index, str
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_set_bindata(struct getdns_list *list, size_t index, struct getdns_bindata *child_bindata);
|
getdns_return_t getdns_list_set_bindata(struct getdns_list *list, size_t index,
|
||||||
|
struct getdns_bindata *child_bindata);
|
||||||
/**
|
/**
|
||||||
* set the integer value of the indexed item (zero based index)
|
* set the integer value of the indexed item (zero based index)
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_list_set_int(struct getdns_list *list, size_t index, uint32_t child_uint32);
|
getdns_return_t getdns_list_set_int(struct getdns_list *list, size_t index,
|
||||||
|
uint32_t child_uint32);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new dictionary with no items
|
* create a new dictionary with no items
|
||||||
|
@ -619,7 +636,8 @@ getdns_dict_copy(struct getdns_dict *srcdict, struct getdns_dict **dstdict);
|
||||||
*/
|
*/
|
||||||
void getdns_dict_destroy(struct getdns_dict *dict);
|
void getdns_dict_destroy(struct getdns_dict *dict);
|
||||||
|
|
||||||
getdns_return_t getdns_dict_set_dict(struct getdns_dict *dict, char *name, struct getdns_dict *child_dict);
|
getdns_return_t getdns_dict_set_dict(struct getdns_dict *dict, char *name,
|
||||||
|
struct getdns_dict *child_dict);
|
||||||
/**
|
/**
|
||||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||||
* this routine makes a copy of the child_list
|
* this routine makes a copy of the child_list
|
||||||
|
@ -628,7 +646,8 @@ getdns_return_t getdns_dict_set_dict(struct getdns_dict *dict, char *name, struc
|
||||||
* @param child_list value to assign to the node identified by name
|
* @param child_list value to assign to the node identified by name
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_set_list(struct getdns_dict *dict, char *name, struct getdns_list *child_list);
|
getdns_return_t getdns_dict_set_list(struct getdns_dict *dict, char *name,
|
||||||
|
struct getdns_list *child_list);
|
||||||
/**
|
/**
|
||||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||||
* this routine makes a copy of the child_bindata
|
* this routine makes a copy of the child_bindata
|
||||||
|
@ -637,7 +656,8 @@ getdns_return_t getdns_dict_set_list(struct getdns_dict *dict, char *name, struc
|
||||||
* @param child_bindata value to assign to the node identified by name
|
* @param child_bindata value to assign to the node identified by name
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_set_bindata(struct getdns_dict *dict, char *name, struct getdns_bindata *child_bindata);
|
getdns_return_t getdns_dict_set_bindata(struct getdns_dict *dict, char *name,
|
||||||
|
struct getdns_bindata *child_bindata);
|
||||||
/**
|
/**
|
||||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||||
* @param dict dictionary in which to add or change the value
|
* @param dict dictionary in which to add or change the value
|
||||||
|
@ -645,71 +665,51 @@ getdns_return_t getdns_dict_set_bindata(struct getdns_dict *dict, char *name, st
|
||||||
* @param child_uint32 value to assign to the node identified by name
|
* @param child_uint32 value to assign to the node identified by name
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t getdns_dict_set_int(struct getdns_dict *dict, char *name, uint32_t child_uint32);
|
getdns_return_t getdns_dict_set_int(struct getdns_dict *dict, char *name,
|
||||||
|
uint32_t child_uint32);
|
||||||
|
|
||||||
/* Callback arguments */
|
/* Callback arguments */
|
||||||
typedef void (*getdns_callback_t)(
|
typedef void (*getdns_callback_t) (getdns_context_t context,
|
||||||
getdns_context_t context,
|
uint16_t callback_type,
|
||||||
uint16_t callback_type,
|
struct getdns_dict * response,
|
||||||
struct getdns_dict *response,
|
void *userarg, getdns_transaction_t transaction_id);
|
||||||
void *userarg,
|
|
||||||
getdns_transaction_t transaction_id);
|
|
||||||
|
|
||||||
/* Function definitions */
|
/* Function definitions */
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general(
|
getdns_general(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
uint16_t request_type,
|
||||||
uint16_t request_type,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callbackfn
|
|
||||||
);
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_address(
|
getdns_address(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callbackfn
|
|
||||||
);
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_hostname(
|
getdns_hostname(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_dict *address,
|
||||||
struct getdns_dict *address,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callbackfn
|
|
||||||
);
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_service(
|
getdns_service(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callbackfn
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t getdns_context_create(
|
getdns_return_t getdns_context_create(getdns_context_t * context,
|
||||||
getdns_context_t *context,
|
int set_from_os);
|
||||||
int set_from_os
|
|
||||||
);
|
|
||||||
|
|
||||||
void
|
void getdns_context_destroy(getdns_context_t context);
|
||||||
getdns_context_destroy(
|
|
||||||
getdns_context_t context
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_cancel_callback(
|
getdns_cancel_callback(getdns_context_t context,
|
||||||
getdns_context_t context,
|
getdns_transaction_t transaction_id);
|
||||||
getdns_transaction_t transaction_id
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup syncfuns Synchronous API functions that do not use callbacks
|
* \defgroup syncfuns Synchronous API functions that do not use callbacks
|
||||||
|
@ -731,14 +731,11 @@ getdns_cancel_callback(
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general_sync(
|
getdns_general_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
uint16_t request_type,
|
||||||
uint16_t request_type,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict **response);
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve address assigned to a DNS name
|
* retrieve address assigned to a DNS name
|
||||||
|
@ -751,13 +748,10 @@ getdns_general_sync(
|
||||||
|
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_address_sync(
|
getdns_address_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict **response);
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve hostname assigned to an IP address
|
* retrieve hostname assigned to an IP address
|
||||||
|
@ -769,13 +763,10 @@ getdns_address_sync(
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_hostname_sync(
|
getdns_hostname_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_dict *address,
|
||||||
struct getdns_dict *address,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict **response);
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve a service assigned to a DNS name
|
* retrieve a service assigned to a DNS name
|
||||||
|
@ -787,48 +778,28 @@ getdns_hostname_sync(
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_service_sync(
|
getdns_service_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict **response);
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
);
|
|
||||||
|
|
||||||
void
|
void getdns_free_sync_request_memory(struct getdns_dict *response);
|
||||||
getdns_free_sync_request_memory(
|
|
||||||
struct getdns_dict *response
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @}
|
/** @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *getdns_convert_dns_name_to_fqdn(char *name_from_dns_response);
|
||||||
getdns_convert_dns_name_to_fqdn(
|
|
||||||
char *name_from_dns_response
|
|
||||||
);
|
|
||||||
|
|
||||||
char *
|
char *getdns_convert_fqdn_to_dns_name(char *fqdn_as_string);
|
||||||
getdns_convert_fqdn_to_dns_name(
|
|
||||||
char *fqdn_as_string
|
|
||||||
);
|
|
||||||
|
|
||||||
char *
|
char *getdns_convert_ulabel_to_alabel(char *ulabel);
|
||||||
getdns_convert_ulabel_to_alabel(
|
|
||||||
char *ulabel
|
|
||||||
);
|
|
||||||
|
|
||||||
char *
|
char *getdns_convert_alabel_to_ulabel(char *alabel);
|
||||||
getdns_convert_alabel_to_ulabel(
|
|
||||||
char *alabel
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_validate_dnssec(
|
getdns_validate_dnssec(struct getdns_bindata *record_to_validate,
|
||||||
struct getdns_bindata *record_to_validate,
|
struct getdns_list *bundle_of_support_records,
|
||||||
struct getdns_list *bundle_of_support_records,
|
struct getdns_list *trust_anchor_rdatas);
|
||||||
struct getdns_list *trust_anchor_rdatas
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a string that describes the dictionary in a human readable form
|
* creates a string that describes the dictionary in a human readable form
|
||||||
|
@ -837,141 +808,91 @@ getdns_validate_dnssec(
|
||||||
* @param dict dictionary to pretty print
|
* @param dict dictionary to pretty print
|
||||||
* @return character array (caller must free this) containing pretty string
|
* @return character array (caller must free this) containing pretty string
|
||||||
*/
|
*/
|
||||||
char *
|
char *getdns_pretty_print_dict(struct getdns_dict *dict);
|
||||||
getdns_pretty_print_dict(struct getdns_dict *dict);
|
|
||||||
|
|
||||||
char *
|
char *getdns_display_ip_address(struct getdns_bindata
|
||||||
getdns_display_ip_address(
|
*bindata_of_ipv4_or_ipv6_address);
|
||||||
struct getdns_bindata *bindata_of_ipv4_or_ipv6_address
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_context_update_callback(
|
getdns_context_set_context_update_callback(getdns_context_t context,
|
||||||
getdns_context_t context,
|
void (*value) (getdns_context_t context, uint16_t changed_item)
|
||||||
void (*value)(getdns_context_t context, uint16_t changed_item)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_resolution_type(
|
getdns_context_set_resolution_type(getdns_context_t context, uint16_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_namespaces(
|
getdns_context_set_namespaces(getdns_context_t context,
|
||||||
getdns_context_t context,
|
size_t namespace_count, uint16_t * namespaces);
|
||||||
size_t namespace_count,
|
|
||||||
uint16_t *namespaces
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_dns_transport(
|
getdns_context_set_dns_transport(getdns_context_t context, uint16_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_limit_outstanding_queries(
|
getdns_context_set_limit_outstanding_queries(getdns_context_t context,
|
||||||
getdns_context_t context,
|
uint16_t limit);
|
||||||
uint16_t limit
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_timeout(
|
getdns_context_set_timeout(getdns_context_t context, uint16_t timeout);
|
||||||
getdns_context_t context,
|
|
||||||
uint16_t timeout
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_follow_redirects(
|
getdns_context_set_follow_redirects(getdns_context_t context, uint16_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_dns_root_servers(
|
getdns_context_set_dns_root_servers(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_list *addresses);
|
||||||
struct getdns_list *addresses
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_append_name(
|
getdns_context_set_append_name(getdns_context_t context, uint16_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_suffix(
|
getdns_context_set_suffix(getdns_context_t context, struct getdns_list *value);
|
||||||
getdns_context_t context,
|
|
||||||
struct getdns_list *value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_dnssec_trust_anchors(
|
getdns_context_set_dnssec_trust_anchors(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_list *value);
|
||||||
struct getdns_list *value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_dnssec_allowed_skew(
|
getdns_context_set_dnssec_allowed_skew(getdns_context_t context,
|
||||||
getdns_context_t context,
|
uint16_t value);
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_stub_resolution(
|
getdns_context_set_stub_resolution(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_list *upstream_list);
|
||||||
struct getdns_list *upstream_list
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_edns_maximum_udp_payload_size(
|
getdns_context_set_edns_maximum_udp_payload_size(getdns_context_t context,
|
||||||
getdns_context_t context,
|
uint16_t value);
|
||||||
uint16_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_edns_extended_rcode(
|
getdns_context_set_edns_extended_rcode(getdns_context_t context,
|
||||||
getdns_context_t context,
|
uint8_t value);
|
||||||
uint8_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_edns_version(
|
getdns_context_set_edns_version(getdns_context_t context, uint8_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint8_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_edns_do_bit(
|
getdns_context_set_edns_do_bit(getdns_context_t context, uint8_t value);
|
||||||
getdns_context_t context,
|
|
||||||
uint8_t value
|
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_memory_allocator(
|
getdns_context_set_memory_allocator(getdns_context_t context,
|
||||||
getdns_context_t context,
|
void (*value) (size_t somesize)
|
||||||
void (*value)(size_t somesize)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_memory_deallocator(
|
getdns_context_set_memory_deallocator(getdns_context_t context,
|
||||||
getdns_context_t context,
|
void (*value) (void *)
|
||||||
void (*value)(void*)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_set_memory_reallocator(
|
getdns_context_set_memory_reallocator(getdns_context_t context,
|
||||||
getdns_context_t context,
|
void (*value) (void *)
|
||||||
void (*value)(void*)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
/* Extension - refactor to abstract async evt loop */
|
/* Extension - refactor to abstract async evt loop */
|
||||||
/* For libevent, which we are using for these examples */
|
/* For libevent, which we are using for these examples */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_extension_set_libevent_base(
|
getdns_extension_set_libevent_base(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct event_base *this_event_base);
|
||||||
struct event_base *this_event_base
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif /* GETDNS_H */
|
#endif /* GETDNS_H */
|
||||||
|
|
|
@ -32,11 +32,10 @@
|
||||||
|
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
|
|
||||||
|
struct getdns_struct_lookup_table
|
||||||
|
{ /* may or may not want to move this into */
|
||||||
struct getdns_struct_lookup_table { /* may or may not want to move this into */
|
int id; /* getdns.h if it's more generally useful */
|
||||||
int id; /* getdns.h if it's more generally useful */
|
const char *name;
|
||||||
const char *name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct getdns_struct_lookup_table getdns_lookup_table;
|
typedef struct getdns_struct_lookup_table getdns_lookup_table;
|
||||||
|
|
|
@ -26,27 +26,44 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
#include <getdns/getdns_error.h>
|
#include <getdns/getdns_error.h>
|
||||||
|
|
||||||
getdns_lookup_table getdns_error_str[] = {
|
getdns_lookup_table getdns_error_str[] = {
|
||||||
{ GETDNS_RETURN_GOOD, "Good" },
|
{GETDNS_RETURN_GOOD, "Good"}
|
||||||
{ GETDNS_RETURN_GENERIC_ERROR, "Generic error" },
|
,
|
||||||
{ GETDNS_RETURN_BAD_DOMAIN_NAME, "Badly-formed domain name" },
|
{GETDNS_RETURN_GENERIC_ERROR, "Generic error"}
|
||||||
{ GETDNS_RETURN_BAD_CONTEXT, "Bad value for a context type" },
|
,
|
||||||
{ GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Did not update the context" },
|
{GETDNS_RETURN_BAD_DOMAIN_NAME, "Badly-formed domain name"}
|
||||||
{ GETDNS_RETURN_UNKNOWN_TRANSACTION, "An attempt was made to cancel a callback with a transaction_id that is not recognized" },
|
,
|
||||||
{ GETDNS_RETURN_NO_SUCH_LIST_ITEM, "A helper function for lists had an index argument that was too high" },
|
{GETDNS_RETURN_BAD_CONTEXT, "Bad value for a context type"}
|
||||||
{ GETDNS_RETURN_NO_SUCH_DICT_NAME, "A helper function for dicts had a name argument that for a name that is not in the dict" },
|
,
|
||||||
{ GETDNS_RETURN_WRONG_TYPE_REQUESTED, "A helper function was supposed to return a certain type for an item, but the wrong type was given" },
|
{GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Did not update the context"}
|
||||||
{ GETDNS_RETURN_NO_SUCH_EXTENSION, "A name in the extensions dict is not a valid extension" },
|
,
|
||||||
{ GETDNS_RETURN_EXTENSION_MISFORMAT, "One or more of the extensions is has a bad format" },
|
{GETDNS_RETURN_UNKNOWN_TRANSACTION,
|
||||||
{ GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED, "A query was made with a context that is using stub resolution and a DNSSEC extension specified" },
|
"An attempt was made to cancel a callback with a transaction_id that is not recognized"}
|
||||||
{ 0, "" }
|
,
|
||||||
|
{GETDNS_RETURN_NO_SUCH_LIST_ITEM,
|
||||||
|
"A helper function for lists had an index argument that was too high"}
|
||||||
|
,
|
||||||
|
{GETDNS_RETURN_NO_SUCH_DICT_NAME,
|
||||||
|
"A helper function for dicts had a name argument that for a name that is not in the dict"}
|
||||||
|
,
|
||||||
|
{GETDNS_RETURN_WRONG_TYPE_REQUESTED,
|
||||||
|
"A helper function was supposed to return a certain type for an item, but the wrong type was given"}
|
||||||
|
,
|
||||||
|
{GETDNS_RETURN_NO_SUCH_EXTENSION,
|
||||||
|
"A name in the extensions dict is not a valid extension"}
|
||||||
|
,
|
||||||
|
{GETDNS_RETURN_EXTENSION_MISFORMAT,
|
||||||
|
"One or more of the extensions is has a bad format"}
|
||||||
|
,
|
||||||
|
{GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED,
|
||||||
|
"A query was made with a context that is using stub resolution and a DNSSEC extension specified"}
|
||||||
|
,
|
||||||
|
{0, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------- getdns_get_errorstr_by_id() */
|
/*---------------------------------------- getdns_get_errorstr_by_id() */
|
||||||
/**
|
/**
|
||||||
* return error string from getdns return
|
* return error string from getdns return
|
||||||
|
@ -55,17 +72,16 @@ getdns_lookup_table getdns_error_str[] = {
|
||||||
* @return string containing error message
|
* @return string containing error message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
getdns_get_errorstr_by_id(uint16_t err)
|
getdns_get_errorstr_by_id(uint16_t err)
|
||||||
{
|
{
|
||||||
getdns_lookup_table *lt;
|
getdns_lookup_table *lt;
|
||||||
|
|
||||||
lt = getdns_error_str;
|
lt = getdns_error_str;
|
||||||
while (lt->name != 0) {
|
while (lt->name != 0) {
|
||||||
if (lt->id == err)
|
if (lt->id == err)
|
||||||
return lt->name;
|
return lt->name;
|
||||||
lt++;
|
lt++;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "util-internal.h"
|
#include "util-internal.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/* stuff to make it compile pedantically */
|
/* stuff to make it compile pedantically */
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
|
@ -43,37 +42,39 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_hostname(
|
getdns_hostname(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_dict * address,
|
||||||
struct getdns_dict *address,
|
struct getdns_dict * extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callback)
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callback
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
struct getdns_bindata *address_data;
|
struct getdns_bindata *address_data;
|
||||||
struct getdns_bindata *address_type;
|
struct getdns_bindata *address_type;
|
||||||
uint16_t req_type;
|
uint16_t req_type;
|
||||||
char *name;
|
char *name;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
|
|
||||||
|
if ((retval =
|
||||||
|
getdns_dict_get_bindata(address, "address_data",
|
||||||
|
&address_data)) != GETDNS_RETURN_GOOD)
|
||||||
|
return retval;
|
||||||
|
if ((retval =
|
||||||
|
getdns_dict_get_bindata(address, "address_type",
|
||||||
|
&address_type)) != GETDNS_RETURN_GOOD)
|
||||||
|
return retval;
|
||||||
|
if ((strncmp(GETDNS_STR_IPV4, (char *) address_type->data,
|
||||||
|
strlen(GETDNS_STR_IPV4)) == 0)
|
||||||
|
|| (strncmp(GETDNS_STR_IPV6, (char *) address_type->data,
|
||||||
|
strlen(GETDNS_STR_IPV6)) == 0))
|
||||||
|
req_type = GETDNS_RRTYPE_PTR;
|
||||||
|
else
|
||||||
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
if ((name = reverse_address((char *) address_data->data)) == 0)
|
||||||
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
return getdns_general(context, name, req_type, extensions,
|
||||||
|
userarg, transaction_id, callback);
|
||||||
|
|
||||||
if ((retval = getdns_dict_get_bindata(address, "address_data", &address_data)) != GETDNS_RETURN_GOOD)
|
return GETDNS_RETURN_GOOD;
|
||||||
return retval;
|
} /* getdns_hostname */
|
||||||
if ((retval = getdns_dict_get_bindata(address, "address_type", &address_type)) != GETDNS_RETURN_GOOD)
|
|
||||||
return retval;
|
|
||||||
if ((strncmp(GETDNS_STR_IPV4, (char *)address_type->data, strlen(GETDNS_STR_IPV4)) == 0) ||
|
|
||||||
(strncmp(GETDNS_STR_IPV6, (char *)address_type->data, strlen(GETDNS_STR_IPV6)) == 0))
|
|
||||||
req_type = GETDNS_RRTYPE_PTR;
|
|
||||||
else
|
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
|
||||||
if ((name = reverse_address((char *)address_data->data)) == 0)
|
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
|
||||||
return getdns_general(context, name, req_type, extensions,
|
|
||||||
userarg, transaction_id, callback);
|
|
||||||
|
|
||||||
return GETDNS_RETURN_GOOD;
|
|
||||||
} /* getdns_hostname */
|
|
||||||
|
|
||||||
/* getdns_hostname.c */
|
/* getdns_hostname.c */
|
||||||
|
|
546
src/list.c
546
src/list.c
|
@ -39,111 +39,106 @@
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_length */
|
/*---------------------------------------- getdns_list_get_length */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_get_length(struct getdns_list *list, size_t *answer)
|
getdns_list_get_length(struct getdns_list * list, size_t * answer)
|
||||||
{
|
{
|
||||||
int retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
int retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && answer != NULL)
|
if (list != NULL && answer != NULL) {
|
||||||
{
|
retval = GETDNS_RETURN_GOOD;
|
||||||
retval = GETDNS_RETURN_GOOD;
|
*answer = list->numinuse;
|
||||||
*answer = list->numinuse;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_get_length */
|
} /* getdns_list_get_length */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_data_type */
|
/*---------------------------------------- getdns_list_get_data_type */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_get_data_type(struct getdns_list *list, size_t index, getdns_data_type *answer)
|
getdns_list_get_data_type(struct getdns_list * list, size_t index,
|
||||||
|
getdns_data_type * answer)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && index < list->numinuse)
|
if (list != NULL && index < list->numinuse) {
|
||||||
{
|
*answer = list->items[index].dtype;
|
||||||
*answer = list->items[index].dtype;
|
retval = GETDNS_RETURN_GOOD;
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
return retval;
|
||||||
return retval;
|
} /* getdns_list_get_data_type */
|
||||||
} /* getdns_list_get_data_type */
|
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_dict */
|
/*---------------------------------------- getdns_list_get_dict */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_get_dict(struct getdns_list *list, size_t index, struct getdns_dict **answer)
|
getdns_list_get_dict(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_dict ** answer)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && index < list->numinuse)
|
if (list != NULL && index < list->numinuse) {
|
||||||
{
|
if (list->items[index].dtype != t_dict)
|
||||||
if(list->items[index].dtype != t_dict)
|
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
else {
|
||||||
else
|
*answer = list->items[index].data.dict;
|
||||||
{
|
retval = GETDNS_RETURN_GOOD;
|
||||||
*answer = list->items[index].data.dict;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_get_dict */
|
} /* getdns_list_get_dict */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_list */
|
/*---------------------------------------- getdns_list_get_list */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_get_list(struct getdns_list *list, size_t index, struct getdns_list **answer)
|
getdns_list_get_list(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_list ** answer)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && index < list->numinuse)
|
if (list != NULL && index < list->numinuse) {
|
||||||
{
|
if (list->items[index].dtype != t_list)
|
||||||
if(list->items[index].dtype != t_list)
|
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
else {
|
||||||
else
|
*answer = list->items[index].data.list;
|
||||||
{
|
retval = GETDNS_RETURN_GOOD;
|
||||||
*answer = list->items[index].data.list;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_get_list */
|
} /* getdns_list_get_list */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_bindata */
|
/*---------------------------------------- getdns_list_get_bindata */
|
||||||
getdns_return_t getdns_list_get_bindata(struct getdns_list *list, size_t index, struct getdns_bindata **answer)
|
getdns_return_t
|
||||||
|
getdns_list_get_bindata(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_bindata ** answer)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && index < list->numinuse)
|
if (list != NULL && index < list->numinuse) {
|
||||||
{
|
if (list->items[index].dtype != t_bindata)
|
||||||
if(list->items[index].dtype != t_bindata)
|
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
else {
|
||||||
else
|
*answer = list->items[index].data.bindata;
|
||||||
{
|
retval = GETDNS_RETURN_GOOD;
|
||||||
*answer = list->items[index].data.bindata;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_get_bindata */
|
} /* getdns_list_get_bindata */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_get_int */
|
/*---------------------------------------- getdns_list_get_int */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_get_int(struct getdns_list *list, size_t index, uint32_t *answer)
|
getdns_list_get_int(struct getdns_list * list, size_t index, uint32_t * answer)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && index < list->numinuse)
|
if (list != NULL && index < list->numinuse) {
|
||||||
{
|
if (list->items[index].dtype != t_int)
|
||||||
if(list->items[index].dtype != t_int)
|
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
else {
|
||||||
else
|
*answer = list->items[index].data.n;
|
||||||
{
|
retval = GETDNS_RETURN_GOOD;
|
||||||
*answer = list->items[index].data.n;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_get_int */
|
} /* getdns_list_get_int */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_realloc */
|
/*---------------------------------------- getdns_list_realloc */
|
||||||
/**
|
/**
|
||||||
|
@ -154,252 +149,267 @@ getdns_list_get_int(struct getdns_list *list, size_t index, uint32_t *answer)
|
||||||
* @return GETDNS_RETURN_GOOD on success, GETDNS_RETURN_GENERIC_ERROR if out of memory
|
* @return GETDNS_RETURN_GOOD on success, GETDNS_RETURN_GENERIC_ERROR if out of memory
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_realloc(struct getdns_list *list)
|
getdns_list_realloc(struct getdns_list * list)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_GENERIC_ERROR;
|
getdns_return_t retval = GETDNS_RETURN_GENERIC_ERROR;
|
||||||
int i;
|
int i;
|
||||||
struct getdns_list_item *newlist;
|
struct getdns_list_item *newlist;
|
||||||
|
|
||||||
if(list != NULL)
|
if (list != NULL) {
|
||||||
{
|
newlist =
|
||||||
newlist = (struct getdns_list_item *) realloc(list->items
|
(struct getdns_list_item *) realloc(list->items,
|
||||||
, (list->numalloc + GETDNS_LIST_BLOCKSZ) * sizeof(struct getdns_list_item));
|
(list->numalloc +
|
||||||
if(newlist != NULL)
|
GETDNS_LIST_BLOCKSZ) *
|
||||||
{
|
sizeof(struct getdns_list_item));
|
||||||
list->items = newlist;
|
if (newlist != NULL) {
|
||||||
for(i=list->numalloc; i<list->numalloc + GETDNS_LIST_BLOCKSZ; i++)
|
list->items = newlist;
|
||||||
{
|
for (i = list->numalloc;
|
||||||
list->items[i].inuse = false;
|
i < list->numalloc + GETDNS_LIST_BLOCKSZ; i++) {
|
||||||
list->items[i].dtype = t_invalid;
|
list->items[i].inuse = false;
|
||||||
}
|
list->items[i].dtype = t_invalid;
|
||||||
list->numalloc += GETDNS_LIST_BLOCKSZ;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
list->numalloc += GETDNS_LIST_BLOCKSZ;
|
||||||
}
|
retval = GETDNS_RETURN_GOOD;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_realloc */
|
} /* getdns_list_realloc */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_copy */
|
/*---------------------------------------- getdns_list_copy */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_copy(struct getdns_list *srclist, struct getdns_list **dstlist)
|
getdns_list_copy(struct getdns_list * srclist, struct getdns_list ** dstlist)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t index;
|
size_t index;
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(srclist != NULL && dstlist != NULL)
|
if (srclist != NULL && dstlist != NULL) {
|
||||||
{
|
*dstlist = getdns_list_create();
|
||||||
*dstlist = getdns_list_create();
|
if (*dstlist != NULL) {
|
||||||
if(*dstlist != NULL)
|
retval = GETDNS_RETURN_GOOD;
|
||||||
{
|
for (i = 0; i < srclist->numinuse; i++) {
|
||||||
retval = GETDNS_RETURN_GOOD;
|
if (getdns_list_add_item(*dstlist,
|
||||||
for(i=0; i<srclist->numinuse; i++)
|
&index) == GETDNS_RETURN_GOOD) {
|
||||||
{
|
(*dstlist)->items[index].inuse = true;
|
||||||
if(getdns_list_add_item(*dstlist, &index) == GETDNS_RETURN_GOOD)
|
(*dstlist)->items[index].dtype =
|
||||||
{
|
srclist->items[i].dtype;
|
||||||
(*dstlist)->items[index].inuse = true;
|
|
||||||
(*dstlist)->items[index].dtype = srclist->items[i].dtype;
|
|
||||||
|
|
||||||
if(srclist->items[i].dtype == t_int)
|
if (srclist->items[i].dtype == t_int)
|
||||||
(*dstlist)->items[index].data.n = srclist->items[i].data.n;
|
(*dstlist)->items[index].data.
|
||||||
else if(srclist->items[i].dtype == t_list)
|
n =
|
||||||
retval = getdns_list_copy(srclist->items[index].data.list
|
srclist->items[i].data.n;
|
||||||
, &((*dstlist)->items[i].data.list));
|
else if (srclist->items[i].dtype ==
|
||||||
else if(srclist->items[i].dtype == t_bindata)
|
t_list)
|
||||||
{
|
retval =
|
||||||
(*dstlist)->items[i].data.bindata = (struct getdns_bindata *)
|
getdns_list_copy(srclist->
|
||||||
malloc(sizeof(getdns_bindata));
|
items[index].data.list,
|
||||||
(*dstlist)->items[i].data.bindata->size = srclist->items[i].data.bindata->size;
|
&((*dstlist)->items[i].
|
||||||
(*dstlist)->items[i].data.bindata->data = (uint8_t *)
|
data.list));
|
||||||
malloc(srclist->items[i].data.bindata->size);
|
else if (srclist->items[i].dtype ==
|
||||||
if((*dstlist)->items[i].data.bindata->data != NULL)
|
t_bindata) {
|
||||||
memcpy((*dstlist)->items[i].data.bindata->data,
|
(*dstlist)->items[i].data.
|
||||||
srclist->items[i].data.bindata->data
|
bindata =
|
||||||
, srclist->items[i].data.bindata->size);
|
(struct getdns_bindata *)
|
||||||
else
|
malloc(sizeof
|
||||||
retval = GETDNS_RETURN_GENERIC_ERROR;
|
(getdns_bindata));
|
||||||
}
|
(*dstlist)->items[i].data.
|
||||||
else if (srclist->items[i].dtype == t_dict)
|
bindata->size =
|
||||||
{
|
srclist->items[i].data.
|
||||||
retval = getdns_dict_copy(srclist->items[index].data.dict,
|
bindata->size;
|
||||||
&((*dstlist)->items[i].data.dict));
|
(*dstlist)->items[i].data.
|
||||||
}
|
bindata->data = (uint8_t *)
|
||||||
}
|
malloc(srclist->items[i].
|
||||||
else {
|
data.bindata->size);
|
||||||
retval = GETDNS_RETURN_GENERIC_ERROR;
|
if ((*dstlist)->items[i].data.
|
||||||
getdns_list_destroy(*dstlist);
|
bindata->data != NULL)
|
||||||
*dstlist = NULL;
|
memcpy((*dstlist)->
|
||||||
}
|
items[i].data.
|
||||||
|
bindata->data,
|
||||||
|
srclist->items[i].
|
||||||
|
data.bindata->data,
|
||||||
|
srclist->items[i].
|
||||||
|
data.bindata->
|
||||||
|
size);
|
||||||
|
else
|
||||||
|
retval =
|
||||||
|
GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
} else if (srclist->items[i].dtype ==
|
||||||
|
t_dict) {
|
||||||
|
retval =
|
||||||
|
getdns_dict_copy(srclist->
|
||||||
|
items[index].data.dict,
|
||||||
|
&((*dstlist)->items[i].
|
||||||
|
data.dict));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
retval = GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
getdns_list_destroy(*dstlist);
|
||||||
|
*dstlist = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(retval != GETDNS_RETURN_GOOD)
|
if (retval != GETDNS_RETURN_GOOD)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
retval = GETDNS_RETURN_GENERIC_ERROR;
|
||||||
retval = GETDNS_RETURN_GENERIC_ERROR;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_copy */
|
} /* getdns_list_copy */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_create */
|
/*---------------------------------------- getdns_list_create */
|
||||||
struct getdns_list *
|
struct getdns_list *
|
||||||
getdns_list_create()
|
getdns_list_create()
|
||||||
{
|
{
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
|
|
||||||
list = (struct getdns_list *) malloc(sizeof(struct getdns_list));
|
list = (struct getdns_list *) malloc(sizeof(struct getdns_list));
|
||||||
if(list != NULL)
|
if (list != NULL) {
|
||||||
{
|
list->numalloc = 0;
|
||||||
list->numalloc = 0;
|
list->numinuse = 0;
|
||||||
list->numinuse = 0;
|
list->items = NULL;
|
||||||
list->items = NULL;
|
|
||||||
|
|
||||||
getdns_list_realloc(list);
|
getdns_list_realloc(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
} /* getdns_list_create */
|
} /* getdns_list_create */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_destroy */
|
/*---------------------------------------- getdns_list_destroy */
|
||||||
void
|
void
|
||||||
getdns_list_destroy(struct getdns_list *list)
|
getdns_list_destroy(struct getdns_list *list)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(list != NULL)
|
if (list != NULL) {
|
||||||
{
|
if (list->items != NULL) {
|
||||||
if(list->items != NULL)
|
for (i = 0; i < list->numinuse; i++) {
|
||||||
{
|
if (list->items[i].dtype == t_list) {
|
||||||
for(i=0; i<list->numinuse; i++)
|
if (list->items[i].dtype == t_list)
|
||||||
{
|
getdns_list_destroy(list->
|
||||||
if(list->items[i].dtype == t_list)
|
items[i].data.list);
|
||||||
{
|
} else if (list->items[i].dtype == t_bindata) {
|
||||||
if(list->items[i].dtype == t_list)
|
if (list->items[i].data.bindata->size >
|
||||||
getdns_list_destroy(list->items[i].data.list);
|
0)
|
||||||
}
|
free(list->items[i].data.
|
||||||
else if(list->items[i].dtype == t_bindata)
|
bindata->data);
|
||||||
{
|
free(list->items[i].data.bindata);
|
||||||
if(list->items[i].data.bindata->size > 0)
|
} else if (list->items[i].dtype == t_dict) {
|
||||||
free(list->items[i].data.bindata->data);
|
getdns_dict_destroy(list->items[i].
|
||||||
free(list->items[i].data.bindata);
|
data.dict);
|
||||||
}
|
}
|
||||||
else if(list->items[i].dtype == t_dict)
|
}
|
||||||
{
|
free(list->items);
|
||||||
getdns_dict_destroy(list->items[i].data.dict);
|
}
|
||||||
}
|
free(list);
|
||||||
}
|
}
|
||||||
free(list->items);
|
} /* getdns_list_destroy */
|
||||||
}
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
} /* getdns_list_destroy */
|
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_add_item */
|
/*---------------------------------------- getdns_list_add_item */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_add_item(struct getdns_list *list, size_t *index)
|
getdns_list_add_item(struct getdns_list *list, size_t * index)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
if(list != NULL && index != NULL)
|
if (list != NULL && index != NULL) {
|
||||||
{
|
if (list->numalloc == list->numinuse)
|
||||||
if(list->numalloc == list->numinuse)
|
retval = getdns_list_realloc(list);
|
||||||
retval = getdns_list_realloc(list);
|
else
|
||||||
else
|
retval = GETDNS_RETURN_GOOD;
|
||||||
retval = GETDNS_RETURN_GOOD;
|
|
||||||
|
|
||||||
if(retval == GETDNS_RETURN_GOOD)
|
if (retval == GETDNS_RETURN_GOOD) {
|
||||||
{
|
*index = list->numinuse;
|
||||||
*index = list->numinuse;
|
list->items[*index].inuse = true;
|
||||||
list->items[*index].inuse = true;
|
list->numinuse++;
|
||||||
list->numinuse++;
|
}
|
||||||
}
|
}
|
||||||
}
|
return retval;
|
||||||
return retval;
|
} /* getdns_list_add_item */
|
||||||
} /* getdns_list_add_item */
|
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_set_dict */
|
/*---------------------------------------- getdns_list_set_dict */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_set_dict(struct getdns_list *list, size_t index, struct getdns_dict *child_dict)
|
getdns_list_set_dict(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_dict * child_dict)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && child_dict != NULL)
|
if (list != NULL && child_dict != NULL) {
|
||||||
{
|
if (list->numinuse > index) {
|
||||||
if(list->numinuse > index)
|
list->items[index].dtype = t_dict;
|
||||||
{
|
retval =
|
||||||
list->items[index].dtype = t_dict;
|
getdns_dict_copy(child_dict,
|
||||||
retval = getdns_dict_copy(child_dict, &(list->items[index].data.dict));
|
&(list->items[index].data.dict));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_set_dict */
|
} /* getdns_list_set_dict */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_set_list */
|
/*---------------------------------------- getdns_set_list */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_set_list(struct getdns_list *list, size_t index, struct getdns_list *child_list)
|
getdns_list_set_list(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_list * child_list)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && child_list != NULL)
|
if (list != NULL && child_list != NULL) {
|
||||||
{
|
if (list->numinuse > index) {
|
||||||
if(list->numinuse > index)
|
list->items[index].dtype = t_list;
|
||||||
{
|
retval =
|
||||||
list->items[index].dtype = t_list;
|
getdns_list_copy(child_list,
|
||||||
retval = getdns_list_copy(child_list, &(list->items[index].data.list));
|
&(list->items[index].data.list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_set_list */
|
} /* getdns_set_list */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_set_bindata */
|
/*---------------------------------------- getdns_list_set_bindata */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_set_bindata(struct getdns_list *list, size_t index, struct getdns_bindata *child_bindata)
|
getdns_list_set_bindata(struct getdns_list * list, size_t index,
|
||||||
|
struct getdns_bindata * child_bindata)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL && child_bindata != NULL)
|
if (list != NULL && child_bindata != NULL) {
|
||||||
{
|
if (list->numinuse > index) {
|
||||||
if(list->numinuse > index)
|
list->items[index].dtype = t_bindata;
|
||||||
{
|
list->items[index].data.bindata =
|
||||||
list->items[index].dtype = t_bindata;
|
(struct getdns_bindata *)
|
||||||
list->items[index].data.bindata = (struct getdns_bindata *)
|
malloc(sizeof(struct getdns_bindata));
|
||||||
malloc(sizeof(struct getdns_bindata));
|
if (list->items[index].data.bindata != NULL) {
|
||||||
if(list->items[index].data.bindata != NULL)
|
list->items[index].data.bindata->size =
|
||||||
{
|
child_bindata->size;
|
||||||
list->items[index].data.bindata->size = child_bindata->size;
|
list->items[index].data.bindata->data =
|
||||||
list->items[index].data.bindata->data = (uint8_t *) malloc(child_bindata->size
|
(uint8_t *) malloc(child_bindata->size *
|
||||||
* sizeof(uint8_t));
|
sizeof(uint8_t));
|
||||||
memcpy(list->items[index].data.bindata->data, child_bindata->data, child_bindata->size);
|
memcpy(list->items[index].data.bindata->data,
|
||||||
retval = GETDNS_RETURN_GOOD;
|
child_bindata->data, child_bindata->size);
|
||||||
}
|
retval = GETDNS_RETURN_GOOD;
|
||||||
else
|
} else
|
||||||
retval = GETDNS_RETURN_GENERIC_ERROR;
|
retval = GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_set_bindata */
|
} /* getdns_list_set_bindata */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_list_set_int */
|
/*---------------------------------------- getdns_list_set_int */
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_list_set_int(struct getdns_list *list, size_t index, uint32_t child_uint32)
|
getdns_list_set_int(struct getdns_list * list, size_t index,
|
||||||
|
uint32_t child_uint32)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if(list != NULL)
|
if (list != NULL) {
|
||||||
{
|
if (list->numinuse > index) {
|
||||||
if(list->numinuse > index)
|
list->items[index].dtype = t_int;
|
||||||
{
|
list->items[index].data.n = child_uint32;
|
||||||
list->items[index].dtype = t_int;
|
retval = GETDNS_RETURN_GOOD;
|
||||||
list->items[index].data.n = child_uint32;
|
}
|
||||||
retval = GETDNS_RETURN_GOOD;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
} /* getdns_list_set_int */
|
} /* getdns_list_set_int */
|
||||||
|
|
||||||
/* getdns_list.c */
|
/* getdns_list.c */
|
||||||
|
|
30
src/list.h
30
src/list.h
|
@ -37,15 +37,17 @@
|
||||||
/**
|
/**
|
||||||
* this structure represents a single item in a list
|
* this structure represents a single item in a list
|
||||||
*/
|
*/
|
||||||
struct getdns_list_item {
|
struct getdns_list_item
|
||||||
int inuse;
|
{
|
||||||
getdns_data_type dtype;
|
int inuse;
|
||||||
union {
|
getdns_data_type dtype;
|
||||||
getdns_list *list;
|
union
|
||||||
getdns_dict *dict;
|
{
|
||||||
int n;
|
getdns_list *list;
|
||||||
getdns_bindata *bindata;
|
getdns_dict *dict;
|
||||||
} data;
|
int n;
|
||||||
|
getdns_bindata *bindata;
|
||||||
|
} data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,11 +59,11 @@ struct getdns_list_item {
|
||||||
* The use cases do not justify working too hard at shrinking the structures.
|
* The use cases do not justify working too hard at shrinking the structures.
|
||||||
* Indexes are 0 based.
|
* Indexes are 0 based.
|
||||||
*/
|
*/
|
||||||
struct getdns_list {
|
struct getdns_list
|
||||||
int numalloc;
|
{
|
||||||
int numinuse;
|
int numalloc;
|
||||||
struct getdns_list_item *items;
|
int numinuse;
|
||||||
|
struct getdns_list_item *items;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -42,144 +42,147 @@
|
||||||
#define gd_malloc(sz) context->memory_allocator(sz)
|
#define gd_malloc(sz) context->memory_allocator(sz)
|
||||||
#define gd_free(ptr) context->memory_deallocator(ptr)
|
#define gd_free(ptr) context->memory_deallocator(ptr)
|
||||||
|
|
||||||
void network_req_free(getdns_network_req* net_req) {
|
void
|
||||||
if (!net_req) {
|
network_req_free(getdns_network_req * net_req)
|
||||||
return;
|
{
|
||||||
}
|
if (!net_req) {
|
||||||
getdns_context_t context = net_req->owner->context;
|
return;
|
||||||
if (net_req->result) {
|
}
|
||||||
ldns_pkt_free(net_req->result);
|
getdns_context_t context = net_req->owner->context;
|
||||||
}
|
if (net_req->result) {
|
||||||
gd_free(net_req);
|
ldns_pkt_free(net_req->result);
|
||||||
|
}
|
||||||
|
gd_free(net_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_network_req* network_req_new(getdns_dns_req* owner,
|
getdns_network_req *
|
||||||
uint16_t request_type,
|
network_req_new(getdns_dns_req * owner,
|
||||||
uint16_t request_class,
|
uint16_t request_type,
|
||||||
struct getdns_dict* extensions) {
|
uint16_t request_class, struct getdns_dict *extensions)
|
||||||
|
{
|
||||||
|
|
||||||
getdns_context_t context = owner->context;
|
getdns_context_t context = owner->context;
|
||||||
getdns_network_req* net_req = gd_malloc(sizeof(getdns_network_req));
|
getdns_network_req *net_req = gd_malloc(sizeof(getdns_network_req));
|
||||||
if (!net_req) {
|
if (!net_req) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
net_req->result = NULL;
|
net_req->result = NULL;
|
||||||
net_req->next = NULL;
|
net_req->next = NULL;
|
||||||
|
|
||||||
net_req->request_type = request_type;
|
net_req->request_type = request_type;
|
||||||
net_req->request_class = request_class;
|
net_req->request_class = request_class;
|
||||||
net_req->unbound_id = -1;
|
net_req->unbound_id = -1;
|
||||||
net_req->state = NET_REQ_NOT_SENT;
|
net_req->state = NET_REQ_NOT_SENT;
|
||||||
net_req->owner = owner;
|
net_req->owner = owner;
|
||||||
|
|
||||||
/* TODO: records and other extensions */
|
/* TODO: records and other extensions */
|
||||||
|
|
||||||
return net_req;
|
return net_req;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dns_req_free(getdns_dns_req* req) {
|
void
|
||||||
if (!req) {
|
dns_req_free(getdns_dns_req * req)
|
||||||
return;
|
{
|
||||||
}
|
if (!req) {
|
||||||
getdns_network_req *net_req = NULL;
|
return;
|
||||||
getdns_context_t context = req->context;
|
}
|
||||||
|
getdns_network_req *net_req = NULL;
|
||||||
|
getdns_context_t context = req->context;
|
||||||
|
|
||||||
/* free extensions */
|
/* free extensions */
|
||||||
getdns_dict_destroy(req->extensions);
|
getdns_dict_destroy(req->extensions);
|
||||||
|
|
||||||
/* free network requests */
|
/* free network requests */
|
||||||
net_req = req->first_req;
|
net_req = req->first_req;
|
||||||
while (net_req) {
|
while (net_req) {
|
||||||
getdns_network_req *next = net_req->next;
|
getdns_network_req *next = net_req->next;
|
||||||
network_req_free(net_req);
|
network_req_free(net_req);
|
||||||
net_req = next;
|
net_req = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup timeout */
|
/* cleanup timeout */
|
||||||
if (req->timeout) {
|
if (req->timeout) {
|
||||||
event_del(req->timeout);
|
event_del(req->timeout);
|
||||||
event_free(req->timeout);
|
event_free(req->timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->local_cb_timer) {
|
if (req->local_cb_timer) {
|
||||||
event_del(req->local_cb_timer);
|
event_del(req->local_cb_timer);
|
||||||
event_free(req->local_cb_timer);
|
event_free(req->local_cb_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free strduped name */
|
/* free strduped name */
|
||||||
free(req->name);
|
free(req->name);
|
||||||
|
|
||||||
gd_free(req);
|
gd_free(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new dns req to be submitted */
|
/* create a new dns req to be submitted */
|
||||||
getdns_dns_req*
|
getdns_dns_req *
|
||||||
dns_req_new(getdns_context_t context,
|
dns_req_new(getdns_context_t context,
|
||||||
struct ub_ctx* unbound,
|
struct ub_ctx *unbound,
|
||||||
const char* name,
|
const char *name, uint16_t request_type, struct getdns_dict *extensions)
|
||||||
uint16_t request_type,
|
{
|
||||||
struct getdns_dict *extensions) {
|
|
||||||
|
|
||||||
getdns_dns_req *result = NULL;
|
getdns_dns_req *result = NULL;
|
||||||
getdns_network_req *req = NULL;
|
getdns_network_req *req = NULL;
|
||||||
getdns_return_t r;
|
getdns_return_t r;
|
||||||
uint32_t both = GETDNS_EXTENSION_FALSE;
|
uint32_t both = GETDNS_EXTENSION_FALSE;
|
||||||
|
|
||||||
result = gd_malloc(sizeof(getdns_dns_req));
|
result = gd_malloc(sizeof(getdns_dns_req));
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->name = strdup(name);
|
result->name = strdup(name);
|
||||||
result->context = context;
|
result->context = context;
|
||||||
result->unbound = unbound;
|
result->unbound = unbound;
|
||||||
result->canceled = 0;
|
result->canceled = 0;
|
||||||
result->current_req = NULL;
|
result->current_req = NULL;
|
||||||
result->first_req = NULL;
|
result->first_req = NULL;
|
||||||
result->trans_id = ldns_get_random();
|
result->trans_id = ldns_get_random();
|
||||||
result->timeout = NULL;
|
result->timeout = NULL;
|
||||||
result->local_cb_timer = NULL;
|
result->local_cb_timer = NULL;
|
||||||
result->ev_base = NULL;
|
result->ev_base = NULL;
|
||||||
|
|
||||||
getdns_dict_copy(extensions, &result->extensions);
|
getdns_dict_copy(extensions, &result->extensions);
|
||||||
|
|
||||||
/* will be set by caller */
|
/* will be set by caller */
|
||||||
result->user_pointer = NULL;
|
result->user_pointer = NULL;
|
||||||
result->user_callback = NULL;
|
result->user_callback = NULL;
|
||||||
|
|
||||||
/* create the requests */
|
/* create the requests */
|
||||||
req = network_req_new(result,
|
req = network_req_new(result,
|
||||||
request_type,
|
request_type, LDNS_RR_CLASS_IN, extensions);
|
||||||
LDNS_RR_CLASS_IN,
|
if (!req) {
|
||||||
extensions);
|
dns_req_free(result);
|
||||||
if (!req) {
|
return NULL;
|
||||||
dns_req_free(result);
|
}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result->current_req = req;
|
result->current_req = req;
|
||||||
result->first_req = req;
|
result->first_req = req;
|
||||||
|
|
||||||
/* tack on A or AAAA if needed */
|
/* tack on A or AAAA if needed */
|
||||||
r = getdns_dict_get_int(extensions,
|
r = getdns_dict_get_int(extensions,
|
||||||
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6,
|
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, &both);
|
||||||
&both);
|
if (r == GETDNS_RETURN_GOOD &&
|
||||||
if (r == GETDNS_RETURN_GOOD &&
|
both == GETDNS_EXTENSION_TRUE &&
|
||||||
both == GETDNS_EXTENSION_TRUE &&
|
(request_type == GETDNS_RRTYPE_A
|
||||||
(request_type == GETDNS_RRTYPE_A || request_type == GETDNS_RRTYPE_AAAA)) {
|
|| request_type == GETDNS_RRTYPE_AAAA)) {
|
||||||
|
|
||||||
uint16_t next_req_type = (request_type == GETDNS_RRTYPE_A) ? GETDNS_RRTYPE_AAAA : GETDNS_RRTYPE_A;
|
uint16_t next_req_type =
|
||||||
getdns_network_req* next_req =
|
(request_type ==
|
||||||
network_req_new(result,
|
GETDNS_RRTYPE_A) ? GETDNS_RRTYPE_AAAA : GETDNS_RRTYPE_A;
|
||||||
next_req_type,
|
getdns_network_req *next_req = network_req_new(result,
|
||||||
LDNS_RR_CLASS_IN,
|
next_req_type,
|
||||||
extensions);
|
LDNS_RR_CLASS_IN,
|
||||||
if (!next_req) {
|
extensions);
|
||||||
dns_req_free(result);
|
if (!next_req) {
|
||||||
return NULL;
|
dns_req_free(result);
|
||||||
}
|
return NULL;
|
||||||
req->next = next_req;
|
}
|
||||||
}
|
req->next = next_req;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,18 +38,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_service(
|
getdns_service(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict * extensions,
|
||||||
struct getdns_dict *extensions,
|
void *userarg,
|
||||||
void *userarg,
|
getdns_transaction_t * transaction_id, getdns_callback_t callback)
|
||||||
getdns_transaction_t *transaction_id,
|
|
||||||
getdns_callback_t callback
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return getdns_general(context, name, GETDNS_RRTYPE_SRV,
|
return getdns_general(context, name, GETDNS_RRTYPE_SRV,
|
||||||
extensions, userarg, transaction_id,
|
extensions, userarg, transaction_id, callback);
|
||||||
callback);
|
} /* getdns_service */
|
||||||
} /* getdns_service */
|
|
||||||
|
|
||||||
/* getdns_core_only.c */
|
/* getdns_core_only.c */
|
||||||
|
|
164
src/sync.c
164
src/sync.c
|
@ -44,119 +44,109 @@
|
||||||
/* stuff to make it compile pedantically */
|
/* stuff to make it compile pedantically */
|
||||||
#define UNUSED_PARAM(x) ((void)(x))
|
#define UNUSED_PARAM(x) ((void)(x))
|
||||||
|
|
||||||
static void sync_callback_func(getdns_context_t context,
|
static void
|
||||||
uint16_t callback_type,
|
sync_callback_func(getdns_context_t context,
|
||||||
struct getdns_dict *response,
|
uint16_t callback_type,
|
||||||
void *userarg,
|
struct getdns_dict *response,
|
||||||
getdns_transaction_t transaction_id) {
|
void *userarg, getdns_transaction_t transaction_id)
|
||||||
|
{
|
||||||
|
|
||||||
*((getdns_dict **)userarg) = response;
|
*((getdns_dict **) userarg) = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_general_sync(
|
getdns_general_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
uint16_t request_type,
|
||||||
uint16_t request_type,
|
struct getdns_dict *extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict **response)
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
getdns_return_t response_status;
|
getdns_return_t response_status;
|
||||||
|
|
||||||
response_status = validate_extensions(extensions);
|
response_status = validate_extensions(extensions);
|
||||||
if (response_status == GETDNS_RETURN_GOOD) {
|
if (response_status == GETDNS_RETURN_GOOD) {
|
||||||
response_status = getdns_general_ub(context->unbound_sync,
|
response_status = getdns_general_ub(context->unbound_sync,
|
||||||
context->event_base_sync,
|
context->event_base_sync,
|
||||||
context, name, request_type,
|
context, name, request_type,
|
||||||
extensions, (void *)response,
|
extensions, (void *) response, NULL, sync_callback_func);
|
||||||
NULL, sync_callback_func);
|
|
||||||
|
|
||||||
event_base_dispatch(context->event_base_sync);
|
event_base_dispatch(context->event_base_sync);
|
||||||
}
|
}
|
||||||
return response_status;
|
return response_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_address_sync(
|
getdns_address_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict * extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict ** response)
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int cleanup_extensions = 0;
|
int cleanup_extensions = 0;
|
||||||
if (!extensions) {
|
if (!extensions) {
|
||||||
extensions = getdns_dict_create();
|
extensions = getdns_dict_create();
|
||||||
cleanup_extensions = 1;
|
cleanup_extensions = 1;
|
||||||
}
|
}
|
||||||
getdns_dict_set_int(extensions,
|
getdns_dict_set_int(extensions,
|
||||||
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6,
|
GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, GETDNS_EXTENSION_TRUE);
|
||||||
GETDNS_EXTENSION_TRUE);
|
|
||||||
|
|
||||||
getdns_return_t result =
|
getdns_return_t result =
|
||||||
getdns_general_sync(context, name, GETDNS_RRTYPE_A,
|
getdns_general_sync(context, name, GETDNS_RRTYPE_A,
|
||||||
extensions, response_length, response);
|
extensions, response_length, response);
|
||||||
if (cleanup_extensions) {
|
if (cleanup_extensions) {
|
||||||
getdns_dict_destroy(extensions);
|
getdns_dict_destroy(extensions);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_hostname_sync(
|
getdns_hostname_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
struct getdns_dict * address,
|
||||||
struct getdns_dict *address,
|
struct getdns_dict * extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict ** response)
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
struct getdns_bindata *address_data;
|
struct getdns_bindata *address_data;
|
||||||
struct getdns_bindata *address_type;
|
struct getdns_bindata *address_type;
|
||||||
uint16_t req_type;
|
uint16_t req_type;
|
||||||
char *name;
|
char *name;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
|
|
||||||
|
if ((retval =
|
||||||
if ((retval = getdns_dict_get_bindata(address, "address_data", &address_data)) != GETDNS_RETURN_GOOD)
|
getdns_dict_get_bindata(address, "address_data",
|
||||||
return retval;
|
&address_data)) != GETDNS_RETURN_GOOD)
|
||||||
if ((retval = getdns_dict_get_bindata(address, "address_type", &address_type)) != GETDNS_RETURN_GOOD)
|
return retval;
|
||||||
return retval;
|
if ((retval =
|
||||||
if ((strncmp(GETDNS_STR_IPV4, (char *)address_type->data, strlen(GETDNS_STR_IPV4)) == 0) ||
|
getdns_dict_get_bindata(address, "address_type",
|
||||||
(strncmp(GETDNS_STR_IPV6, (char *)address_type->data, strlen(GETDNS_STR_IPV6)) == 0))
|
&address_type)) != GETDNS_RETURN_GOOD)
|
||||||
req_type = GETDNS_RRTYPE_PTR;
|
return retval;
|
||||||
else
|
if ((strncmp(GETDNS_STR_IPV4, (char *) address_type->data,
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
strlen(GETDNS_STR_IPV4)) == 0)
|
||||||
if ((name = reverse_address((char *)address_data)) == 0)
|
|| (strncmp(GETDNS_STR_IPV6, (char *) address_type->data,
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
strlen(GETDNS_STR_IPV6)) == 0))
|
||||||
return getdns_general_sync(context, name, req_type, extensions,
|
req_type = GETDNS_RRTYPE_PTR;
|
||||||
response_length, response);
|
else
|
||||||
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
if ((name = reverse_address((char *) address_data)) == 0)
|
||||||
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
return getdns_general_sync(context, name, req_type, extensions,
|
||||||
|
response_length, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_service_sync(
|
getdns_service_sync(getdns_context_t context,
|
||||||
getdns_context_t context,
|
const char *name,
|
||||||
const char *name,
|
struct getdns_dict * extensions,
|
||||||
struct getdns_dict *extensions,
|
uint32_t * response_length, struct getdns_dict ** response)
|
||||||
uint32_t *response_length,
|
|
||||||
struct getdns_dict **response
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return getdns_general_sync(context, name, GETDNS_RRTYPE_SRV, extensions,
|
return getdns_general_sync(context, name, GETDNS_RRTYPE_SRV,
|
||||||
response_length, response);
|
extensions, response_length, response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
getdns_free_sync_request_memory(
|
getdns_free_sync_request_memory(struct getdns_dict *response)
|
||||||
struct getdns_dict *response
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
getdns_dict_destroy(response);
|
getdns_dict_destroy(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getdns_core_sync.c */
|
/* getdns_core_sync.c */
|
||||||
|
|
|
@ -31,57 +31,57 @@
|
||||||
#include "testmessages.h"
|
#include "testmessages.h"
|
||||||
|
|
||||||
static char *testprog = NULL;
|
static char *testprog = NULL;
|
||||||
static char **cases = NULL;
|
static char **cases = NULL;
|
||||||
static int ncases = 0;
|
static int ncases = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
tstmsg_prog_begin(char *prognm)
|
tstmsg_prog_begin(char *prognm)
|
||||||
{
|
{
|
||||||
if(testprog != NULL)
|
if (testprog != NULL) {
|
||||||
{ tstmsg_prog_end();
|
tstmsg_prog_end();
|
||||||
free(testprog);
|
free(testprog);
|
||||||
}
|
}
|
||||||
testprog = strdup(prognm);
|
testprog = strdup(prognm);
|
||||||
printf("TESTPROG %s START\n", testprog);
|
printf("TESTPROG %s START\n", testprog);
|
||||||
} /* tstmsg_prog_begin */
|
} /* tstmsg_prog_begin */
|
||||||
|
|
||||||
void
|
void
|
||||||
tstmsg_prog_end()
|
tstmsg_prog_end()
|
||||||
{
|
{
|
||||||
printf("TESTPROG %s END\n", testprog);
|
printf("TESTPROG %s END\n", testprog);
|
||||||
free(testprog);
|
free(testprog);
|
||||||
} /* tstmsg_prog_end */
|
} /* tstmsg_prog_end */
|
||||||
|
|
||||||
void
|
void
|
||||||
tstmsg_case_begin(char *casenm)
|
tstmsg_case_begin(char *casenm)
|
||||||
{
|
{
|
||||||
ncases++;
|
ncases++;
|
||||||
cases = (char **) realloc(cases, sizeof(char *) * ncases);
|
cases = (char **) realloc(cases, sizeof(char *) * ncases);
|
||||||
cases[ncases-1] = strdup(casenm);
|
cases[ncases - 1] = strdup(casenm);
|
||||||
|
|
||||||
printf("TESTCASE %s:%s BEGIN\n", testprog, cases[ncases-1]);
|
printf("TESTCASE %s:%s BEGIN\n", testprog, cases[ncases - 1]);
|
||||||
} /* tstmsg_case_begin */
|
} /* tstmsg_case_begin */
|
||||||
|
|
||||||
void
|
void
|
||||||
tstmsg_case_end(void)
|
tstmsg_case_end(void)
|
||||||
{
|
{
|
||||||
if(ncases > 0)
|
if (ncases > 0) {
|
||||||
{
|
printf("TESTCASE %s:%s END\n", testprog, cases[ncases - 1]);
|
||||||
printf("TESTCASE %s:%s END\n", testprog, cases[ncases-1]);
|
ncases--;
|
||||||
ncases--;
|
free(cases[ncases]);
|
||||||
free(cases[ncases]);
|
if (ncases) {
|
||||||
if (ncases) {
|
cases =
|
||||||
cases = (char **) realloc(cases, sizeof(char *) * ncases);
|
(char **) realloc(cases, sizeof(char *) * ncases);
|
||||||
} else {
|
} else {
|
||||||
cases = NULL;
|
cases = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* tstmsg_case_end */
|
} /* tstmsg_case_end */
|
||||||
|
|
||||||
void
|
void
|
||||||
tstmsg_case_msg(char *msg)
|
tstmsg_case_msg(char *msg)
|
||||||
{
|
{
|
||||||
printf(" %s:%s: %s\n", testprog, cases[ncases-1], msg);
|
printf(" %s:%s: %s\n", testprog, cases[ncases - 1], msg);
|
||||||
} /* tstmsg_case_msg */
|
} /* tstmsg_case_msg */
|
||||||
|
|
||||||
/* testmessages.c */
|
/* testmessages.c */
|
||||||
|
|
|
@ -41,71 +41,81 @@
|
||||||
void
|
void
|
||||||
tst_bindatasetget(void)
|
tst_bindatasetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
char key[20];
|
char key[20];
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
struct getdns_bindata *ans_bdata;
|
struct getdns_bindata *ans_bdata;
|
||||||
struct getdns_bindata *bindata;
|
struct getdns_bindata *bindata;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_bindatasetget");
|
tstmsg_case_begin("tst_bindatasetget");
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* test int get function against empty dict and with bogus params */
|
/* test int get function against empty dict and with bogus params */
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_bindata() empty dict");
|
tstmsg_case_msg("getdns_dict_get_bindata() empty dict");
|
||||||
retval = getdns_dict_get_bindata(NULL, key, &ans_bdata);
|
retval = getdns_dict_get_bindata(NULL, key, &ans_bdata);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_dict_get_bindata(dict, key, NULL);
|
retval = getdns_dict_get_bindata(dict, key, NULL);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_bindata(dict, key, NULL),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_bindata(dict, key, NULL),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_bindata(dict, NULL, &ans_bindata)");
|
tstmsg_case_msg("getdns_dict_get_bindata(dict, NULL, &ans_bindata)");
|
||||||
retval = getdns_dict_get_bindata(dict, NULL, &ans_bdata);
|
retval = getdns_dict_get_bindata(dict, NULL, &ans_bdata);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_bindata,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_dict_get_bindata,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
|
tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
|
||||||
retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
|
retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
|
||||||
sprintf(msg, "line %d: getdns_list_get_bindata,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_list_get_bindata,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
/* TODO: test getdns_dict_set functions with bogus params */
|
/* TODO: test getdns_dict_set functions with bogus params */
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
bindata = (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
|
bindata =
|
||||||
bindata->size = strlen("foobar") + 1;
|
(struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
|
||||||
bindata->data = (void *) strdup("foobar");
|
bindata->size = strlen("foobar") + 1;
|
||||||
|
bindata->data = (void *) strdup("foobar");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_set_bindata(dict, key, bindata)");
|
tstmsg_case_msg("getdns_dict_set_bindata(dict, key, bindata)");
|
||||||
retval = getdns_dict_set_bindata(dict, key, bindata);
|
retval = getdns_dict_set_bindata(dict, key, bindata);
|
||||||
sprintf(msg, "line %d: getdns_dict_set_bindata,retval=%d,key=%s", __LINE__, retval, key);
|
sprintf(msg, "line %d: getdns_dict_set_bindata,retval=%d,key=%s",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
|
tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
|
||||||
retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
|
retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_bindata,retval=%d,key=%s,data=%s", __LINE__, retval, key, ans_bdata->data);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_bindata,retval=%d,key=%s,data=%s",
|
||||||
|
__LINE__, retval, key, ans_bdata->data);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
free(bindata->data);
|
free(bindata->data);
|
||||||
free(bindata);
|
free(bindata);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_bindatasetget */
|
} /* tst_bindatasetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_dictsetget */
|
/*---------------------------------------- tst_dictsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -114,75 +124,83 @@ tst_bindatasetget(void)
|
||||||
void
|
void
|
||||||
tst_dictsetget(void)
|
tst_dictsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
char key[20];
|
char key[20];
|
||||||
uint32_t int1;
|
uint32_t int1;
|
||||||
uint32_t int2;
|
uint32_t int2;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_dict *newdict;
|
struct getdns_dict *newdict;
|
||||||
struct getdns_dict *ansdict;
|
struct getdns_dict *ansdict;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_dictsetget");
|
tstmsg_case_begin("tst_dictsetget");
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* test get function against empty list and with bogus params */
|
/* test get function against empty list and with bogus params */
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_dict() empty dict");
|
tstmsg_case_msg("getdns_dict_get_dict() empty dict");
|
||||||
retval = getdns_dict_get_dict(NULL, key, &ansdict);
|
retval = getdns_dict_get_dict(NULL, key, &ansdict);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_dict(NULL, key, &ansdict),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_dict(NULL, key, &ansdict),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_dict_get_dict(dict, key, NULL);
|
retval = getdns_dict_get_dict(dict, key, NULL);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_dict(dict, key, NULL),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_dict(dict, key, NULL),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_dict(dict, NULL, &ansdict)");
|
tstmsg_case_msg("getdns_dict_get_dict(dict, NULL, &ansdict)");
|
||||||
retval = getdns_dict_get_dict(dict, NULL, &ansdict);
|
retval = getdns_dict_get_dict(dict, NULL, &ansdict);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_dict,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_dict_get_dict,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
|
tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
|
||||||
retval = getdns_dict_get_dict(dict, key, &ansdict);
|
retval = getdns_dict_get_dict(dict, key, &ansdict);
|
||||||
sprintf(msg, "line %d: getdns_list_get_dict,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_list_get_dict,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
/* TODO: test getdns_dict_set functions with bogus params */
|
/* TODO: test getdns_dict_set functions with bogus params */
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
newdict = getdns_dict_create();
|
newdict = getdns_dict_create();
|
||||||
getdns_dict_set_int(newdict, "foo", 42);
|
getdns_dict_set_int(newdict, "foo", 42);
|
||||||
getdns_dict_set_int(newdict, "bar", 52);
|
getdns_dict_set_int(newdict, "bar", 52);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_set_dict(dict, key, newdict)");
|
tstmsg_case_msg("getdns_dict_set_dict(dict, key, newdict)");
|
||||||
retval = getdns_dict_set_dict(dict, key, newdict);
|
retval = getdns_dict_set_dict(dict, key, newdict);
|
||||||
sprintf(msg, "line %d: getdns_dict_set_dict,retval=%d,key=%s", __LINE__, retval, key);
|
sprintf(msg, "line %d: getdns_dict_set_dict,retval=%d,key=%s",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key);
|
||||||
getdns_dict_destroy(newdict);
|
tstmsg_case_msg(msg);
|
||||||
|
getdns_dict_destroy(newdict);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
|
tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
|
||||||
retval = getdns_dict_get_dict(dict, key, &ansdict);
|
retval = getdns_dict_get_dict(dict, key, &ansdict);
|
||||||
getdns_dict_get_int(ansdict, "foo", &int1);
|
getdns_dict_get_int(ansdict, "foo", &int1);
|
||||||
getdns_dict_get_int(ansdict, "bar", &int2);
|
getdns_dict_get_int(ansdict, "bar", &int2);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_dict,retval=%d,key=%s,int1=%d,int2=%d"
|
sprintf(msg,
|
||||||
, __LINE__, retval, key, int1, int2);
|
"line %d: getdns_dict_get_dict,retval=%d,key=%s,int1=%d,int2=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, int1, int2);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_dictsetget */
|
} /* tst_dictsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_getnames */
|
/*---------------------------------------- tst_getnames */
|
||||||
/**
|
/**
|
||||||
|
@ -191,84 +209,83 @@ tst_dictsetget(void)
|
||||||
void
|
void
|
||||||
tst_getnames(void)
|
tst_getnames(void)
|
||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
size_t llen;
|
size_t llen;
|
||||||
uint32_t ansint;
|
uint32_t ansint;
|
||||||
int i;
|
int i;
|
||||||
getdns_return_t result;
|
getdns_return_t result;
|
||||||
getdns_data_type dtype;
|
getdns_data_type dtype;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_getnames");
|
tstmsg_case_begin("tst_getnames");
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* degenerative use cases */
|
/* degenerative use cases */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_names(NULL, &list)");
|
tstmsg_case_msg("getdns_dict_get_names(NULL, &list)");
|
||||||
getdns_dict_get_names(NULL, &list);
|
getdns_dict_get_names(NULL, &list);
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_names(dict, NULL)");
|
tstmsg_case_msg("getdns_dict_get_names(dict, NULL)");
|
||||||
getdns_dict_get_names(dict, NULL);
|
getdns_dict_get_names(dict, NULL);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_names(dict, &list), empty dictionary");
|
tstmsg_case_msg
|
||||||
getdns_dict_get_names(dict, &list);
|
("getdns_dict_get_names(dict, &list), empty dictionary");
|
||||||
getdns_list_destroy(list);
|
getdns_dict_get_names(dict, &list);
|
||||||
|
getdns_list_destroy(list);
|
||||||
/* legit use case, add items out of order to exercise tree */
|
|
||||||
/* TODO: add elements of type dict, bindata, list to the dict */
|
|
||||||
|
|
||||||
i = 0;
|
/* legit use case, add items out of order to exercise tree */
|
||||||
getdns_dict_set_int(dict, "foo", i++);
|
/* TODO: add elements of type dict, bindata, list to the dict */
|
||||||
getdns_dict_set_int(dict, "bar", i++);
|
|
||||||
getdns_dict_set_int(dict, "quz", i++);
|
|
||||||
getdns_dict_set_int(dict, "alpha", i++);
|
|
||||||
|
|
||||||
getdns_dict_get_names(dict, &list);
|
i = 0;
|
||||||
|
getdns_dict_set_int(dict, "foo", i++);
|
||||||
|
getdns_dict_set_int(dict, "bar", i++);
|
||||||
|
getdns_dict_set_int(dict, "quz", i++);
|
||||||
|
getdns_dict_set_int(dict, "alpha", i++);
|
||||||
|
|
||||||
result = getdns_list_get_length(list, &llen);
|
getdns_dict_get_names(dict, &list);
|
||||||
if(llen != i)
|
|
||||||
{
|
|
||||||
tstmsg_case_msg("getdns_list_get_length returned unreasonable length, exiting");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(index=0; index<llen; index++)
|
result = getdns_list_get_length(list, &llen);
|
||||||
{
|
if (llen != i) {
|
||||||
getdns_list_get_data_type(list, index, &dtype);
|
tstmsg_case_msg
|
||||||
printf(" list item %d: ", (int) index);
|
("getdns_list_get_length returned unreasonable length, exiting");
|
||||||
switch(dtype)
|
return;
|
||||||
{
|
}
|
||||||
case t_bindata:
|
|
||||||
printf("NOTIMPLEMENTED");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_dict:
|
for (index = 0; index < llen; index++) {
|
||||||
printf("NOTIMPLEMENTED");
|
getdns_list_get_data_type(list, index, &dtype);
|
||||||
break;
|
printf(" list item %d: ", (int) index);
|
||||||
|
switch (dtype) {
|
||||||
|
case t_bindata:
|
||||||
|
printf("NOTIMPLEMENTED");
|
||||||
|
break;
|
||||||
|
|
||||||
case t_int:
|
case t_dict:
|
||||||
getdns_list_get_int(list, index, &ansint);
|
printf("NOTIMPLEMENTED");
|
||||||
printf("t_int, value=%d\n", ansint);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case t_invalid:
|
case t_int:
|
||||||
printf("data type invalid");
|
getdns_list_get_int(list, index, &ansint);
|
||||||
break;
|
printf("t_int, value=%d\n", ansint);
|
||||||
|
break;
|
||||||
|
|
||||||
case t_list:
|
case t_invalid:
|
||||||
printf("NOTIMPLEMENTED");
|
printf("data type invalid");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
case t_list:
|
||||||
getdns_list_destroy(list);
|
printf("NOTIMPLEMENTED");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tstmsg_case_end();
|
getdns_dict_destroy(dict);
|
||||||
} /* tst_getnames */
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
|
tstmsg_case_end();
|
||||||
|
} /* tst_getnames */
|
||||||
|
|
||||||
/*---------------------------------------- tst_listsetget */
|
/*---------------------------------------- tst_listsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -277,78 +294,86 @@ tst_getnames(void)
|
||||||
void
|
void
|
||||||
tst_listsetget(void)
|
tst_listsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
char key[20];
|
char key[20];
|
||||||
size_t index;
|
size_t index;
|
||||||
uint32_t int1;
|
uint32_t int1;
|
||||||
uint32_t int2;
|
uint32_t int2;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_list *newlist;
|
struct getdns_list *newlist;
|
||||||
struct getdns_list *anslist;
|
struct getdns_list *anslist;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_listsetget");
|
tstmsg_case_begin("tst_listsetget");
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* test get function against empty list and with bogus params */
|
/* test get function against empty list and with bogus params */
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_list() empty dict");
|
tstmsg_case_msg("getdns_dict_get_list() empty dict");
|
||||||
retval = getdns_dict_get_list(NULL, key, &anslist);
|
retval = getdns_dict_get_list(NULL, key, &anslist);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_list(NULL, key, &anslist),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_list(NULL, key, &anslist),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_dict_get_list(dict, key, NULL);
|
retval = getdns_dict_get_list(dict, key, NULL);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_list(dict, key, NULL),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_list(dict, key, NULL),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_list(dict, NULL, &anslist)");
|
tstmsg_case_msg("getdns_dict_get_list(dict, NULL, &anslist)");
|
||||||
retval = getdns_dict_get_list(dict, NULL, &anslist);
|
retval = getdns_dict_get_list(dict, NULL, &anslist);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_list,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_dict_get_list,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
|
tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
|
||||||
retval = getdns_dict_get_list(dict, key, &anslist);
|
retval = getdns_dict_get_list(dict, key, &anslist);
|
||||||
sprintf(msg, "line %d: getdns_list_get_list,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_list_get_list,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
/* TODO: test getdns_dict_set functions with bogus params */
|
/* TODO: test getdns_dict_set functions with bogus params */
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
newlist = getdns_list_create();
|
newlist = getdns_list_create();
|
||||||
getdns_list_add_item(newlist, &index);
|
getdns_list_add_item(newlist, &index);
|
||||||
getdns_list_set_int(newlist, index, 42);
|
getdns_list_set_int(newlist, index, 42);
|
||||||
getdns_list_add_item(newlist, &index);
|
getdns_list_add_item(newlist, &index);
|
||||||
getdns_list_set_int(newlist, index, 52);
|
getdns_list_set_int(newlist, index, 52);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_set_list(dict, key, newlist)");
|
tstmsg_case_msg("getdns_dict_set_list(dict, key, newlist)");
|
||||||
retval = getdns_dict_set_list(dict, key, newlist);
|
retval = getdns_dict_set_list(dict, key, newlist);
|
||||||
sprintf(msg, "line %d: getdns_dict_set_list,retval=%d,key=%s", __LINE__, retval, key);
|
sprintf(msg, "line %d: getdns_dict_set_list,retval=%d,key=%s",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key);
|
||||||
getdns_list_destroy(newlist);
|
tstmsg_case_msg(msg);
|
||||||
|
getdns_list_destroy(newlist);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
|
tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
|
||||||
retval = getdns_dict_get_list(dict, key, &anslist);
|
retval = getdns_dict_get_list(dict, key, &anslist);
|
||||||
getdns_list_get_int(anslist, 0, &int1);
|
getdns_list_get_int(anslist, 0, &int1);
|
||||||
getdns_list_get_int(anslist, 1, &int2);
|
getdns_list_get_int(anslist, 1, &int2);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_list,retval=%d,key=%s,int1=%d,int2=%d"
|
sprintf(msg,
|
||||||
, __LINE__, retval, key, int1, int2);
|
"line %d: getdns_dict_get_list,retval=%d,key=%s,int1=%d,int2=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, int1, int2);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_listsetget */
|
} /* tst_listsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_intsetget */
|
/*---------------------------------------- tst_intsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -357,85 +382,97 @@ tst_listsetget(void)
|
||||||
void
|
void
|
||||||
tst_intsetget(void)
|
tst_intsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
char key[20];
|
char key[20];
|
||||||
uint32_t ans_int;
|
uint32_t ans_int;
|
||||||
uint32_t newint;
|
uint32_t newint;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
getdns_data_type dtype;
|
getdns_data_type dtype;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_intsetget");
|
tstmsg_case_begin("tst_intsetget");
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* test int get function against empty list and with bogus params */
|
/* test int get function against empty list and with bogus params */
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_int() empty dict");
|
tstmsg_case_msg("getdns_dict_get_int() empty dict");
|
||||||
retval = getdns_dict_get_int(NULL, key, &ans_int);
|
retval = getdns_dict_get_int(NULL, key, &ans_int);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_int(NULL, key, &ans_int),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_int(NULL, key, &ans_int),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_dict_get_int(dict, key, NULL);
|
retval = getdns_dict_get_int(dict, key, NULL);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_int(dict, key, NULL),retval = %d", __LINE__, retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_int(dict, key, NULL),retval = %d",
|
||||||
|
__LINE__, retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_int(dict, NULL, &ans_int)");
|
tstmsg_case_msg("getdns_dict_get_int(dict, NULL, &ans_int)");
|
||||||
retval = getdns_dict_get_int(dict, NULL, &ans_int);
|
retval = getdns_dict_get_int(dict, NULL, &ans_int);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_int,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_dict_get_int,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
||||||
retval = getdns_dict_get_int(dict, key, &ans_int);
|
retval = getdns_dict_get_int(dict, key, &ans_int);
|
||||||
sprintf(msg, "line %d: getdns_list_get_int,retval = %d", __LINE__, retval);
|
sprintf(msg, "line %d: getdns_list_get_int,retval = %d", __LINE__,
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
/* TODO: test getdns_dict_set functions with bogus params */
|
/* TODO: test getdns_dict_set functions with bogus params */
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
strcpy(key, "foo");
|
strcpy(key, "foo");
|
||||||
newint = 42;
|
newint = 42;
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
|
tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
|
||||||
retval = getdns_dict_set_int(dict, key, newint);
|
retval = getdns_dict_set_int(dict, key, newint);
|
||||||
sprintf(msg, "line %d: getdns_dict_set_int,retval=%d,key=%s,int=%d", __LINE__, retval, key, newint);
|
sprintf(msg, "line %d: getdns_dict_set_int,retval=%d,key=%s,int=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, newint);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
||||||
retval = getdns_dict_get_int(dict, key, &ans_int);
|
retval = getdns_dict_get_int(dict, key, &ans_int);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_int,retval=%d,key=%s,int=%d", __LINE__, retval, key, ans_int);
|
sprintf(msg, "line %d: getdns_dict_get_int,retval=%d,key=%s,int=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, ans_int);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
strcpy(key, "bar");
|
strcpy(key, "bar");
|
||||||
newint = 52;
|
newint = 52;
|
||||||
tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
|
tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
|
||||||
retval = getdns_dict_set_int(dict, key, newint);
|
retval = getdns_dict_set_int(dict, key, newint);
|
||||||
sprintf(msg, "line %d: getdns_dict_set_int,retval=%d,key=%s,int=%d", __LINE__, retval, key, newint);
|
sprintf(msg, "line %d: getdns_dict_set_int,retval=%d,key=%s,int=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, newint);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
|
||||||
retval = getdns_dict_get_int(dict, key, &ans_int);
|
retval = getdns_dict_get_int(dict, key, &ans_int);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_int,retval=%d,key=%s,int=%d", __LINE__, retval, key, ans_int);
|
sprintf(msg, "line %d: getdns_dict_get_int,retval=%d,key=%s,int=%d",
|
||||||
tstmsg_case_msg(msg);
|
__LINE__, retval, key, ans_int);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_get_data_type(dict, key, &dtype)");
|
tstmsg_case_msg("getdns_dict_get_data_type(dict, key, &dtype)");
|
||||||
retval = getdns_dict_get_data_type(dict, key, &dtype);
|
retval = getdns_dict_get_data_type(dict, key, &dtype);
|
||||||
sprintf(msg, "line %d: getdns_dict_get_data_type,retval=%d,key=%s,dtype=%d", __LINE__, retval, key, dtype);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"line %d: getdns_dict_get_data_type,retval=%d,key=%s,dtype=%d",
|
||||||
|
__LINE__, retval, key, dtype);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_intsetget */
|
} /* tst_intsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_copy */
|
/*---------------------------------------- tst_copy */
|
||||||
/**
|
/**
|
||||||
|
@ -444,45 +481,45 @@ tst_intsetget(void)
|
||||||
void
|
void
|
||||||
tst_copy(void)
|
tst_copy(void)
|
||||||
{
|
{
|
||||||
char *dictstr = NULL;
|
char *dictstr = NULL;
|
||||||
struct getdns_dict *dict1 = NULL;
|
struct getdns_dict *dict1 = NULL;
|
||||||
struct getdns_dict *dict2 = NULL;
|
struct getdns_dict *dict2 = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_copy");
|
tstmsg_case_begin("tst_copy");
|
||||||
|
|
||||||
tstmsg_case_msg("empty list cases");
|
tstmsg_case_msg("empty list cases");
|
||||||
|
|
||||||
getdns_dict_copy(NULL, NULL);
|
getdns_dict_copy(NULL, NULL);
|
||||||
dict1 = getdns_dict_create();
|
dict1 = getdns_dict_create();
|
||||||
getdns_dict_copy(dict1, &dict2);
|
getdns_dict_copy(dict1, &dict2);
|
||||||
getdns_dict_destroy(dict2);
|
getdns_dict_destroy(dict2);
|
||||||
getdns_dict_copy(NULL, &dict1);
|
getdns_dict_copy(NULL, &dict1);
|
||||||
|
|
||||||
tstmsg_case_msg("dict1 populate");
|
tstmsg_case_msg("dict1 populate");
|
||||||
|
|
||||||
getdns_dict_set_int(dict1, "foo", 42);
|
getdns_dict_set_int(dict1, "foo", 42);
|
||||||
getdns_dict_set_int(dict1, "bar", 52);
|
getdns_dict_set_int(dict1, "bar", 52);
|
||||||
getdns_dict_set_int(dict1, "quz", 62);
|
getdns_dict_set_int(dict1, "quz", 62);
|
||||||
|
|
||||||
dictstr = getdns_pretty_print_dict(dict1);
|
dictstr = getdns_pretty_print_dict(dict1);
|
||||||
printf("%s", dictstr);
|
printf("%s", dictstr);
|
||||||
free(dictstr);
|
free(dictstr);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_copy(dict1, &dict2)");
|
tstmsg_case_msg("getdns_dict_copy(dict1, &dict2)");
|
||||||
|
|
||||||
getdns_dict_copy(dict1, &dict2);
|
getdns_dict_copy(dict1, &dict2);
|
||||||
|
|
||||||
dictstr = getdns_pretty_print_dict(dict2);
|
dictstr = getdns_pretty_print_dict(dict2);
|
||||||
printf("%s", dictstr);
|
printf("%s", dictstr);
|
||||||
free(dictstr);
|
free(dictstr);
|
||||||
|
|
||||||
getdns_dict_destroy(dict1);
|
getdns_dict_destroy(dict1);
|
||||||
getdns_dict_destroy(dict2);
|
getdns_dict_destroy(dict2);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_copy */
|
} /* tst_copy */
|
||||||
|
|
||||||
/*---------------------------------------- tst_create */
|
/*---------------------------------------- tst_create */
|
||||||
/**
|
/**
|
||||||
|
@ -491,28 +528,27 @@ tst_copy(void)
|
||||||
void
|
void
|
||||||
tst_create(void)
|
tst_create(void)
|
||||||
{
|
{
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
|
|
||||||
/* make sure we can do a simple create/destroy first */
|
/* make sure we can do a simple create/destroy first */
|
||||||
|
|
||||||
tstmsg_case_begin("tst_create");
|
tstmsg_case_begin("tst_create");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_create");
|
tstmsg_case_msg("getdns_dict_create");
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
if(dict != NULL)
|
if (dict != NULL) {
|
||||||
{
|
tstmsg_case_msg("getdns_dict_destroy(dict)");
|
||||||
tstmsg_case_msg("getdns_dict_destroy(dict)");
|
getdns_dict_destroy(dict);
|
||||||
getdns_dict_destroy(dict);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_dict_destroy(NULL)");
|
tstmsg_case_msg("getdns_dict_destroy(NULL)");
|
||||||
getdns_dict_destroy(NULL);
|
getdns_dict_destroy(NULL);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_create */
|
} /* tst_create */
|
||||||
|
|
||||||
/*---------------------------------------- main */
|
/*---------------------------------------- main */
|
||||||
/**
|
/**
|
||||||
|
@ -521,25 +557,25 @@ tst_create(void)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
tstmsg_prog_begin("tests_dict");
|
tstmsg_prog_begin("tests_dict");
|
||||||
|
|
||||||
tst_create();
|
tst_create();
|
||||||
|
|
||||||
tst_bindatasetget();
|
tst_bindatasetget();
|
||||||
|
|
||||||
tst_dictsetget();
|
tst_dictsetget();
|
||||||
|
|
||||||
tst_intsetget();
|
tst_intsetget();
|
||||||
|
|
||||||
tst_listsetget();
|
tst_listsetget();
|
||||||
|
|
||||||
tst_getnames();
|
tst_getnames();
|
||||||
|
|
||||||
tst_copy();
|
tst_copy();
|
||||||
|
|
||||||
tstmsg_prog_end();
|
tstmsg_prog_end();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* end tests_dict.c */
|
/* end tests_dict.c */
|
||||||
|
|
|
@ -45,76 +45,82 @@
|
||||||
void
|
void
|
||||||
tst_bindatasetget(void)
|
tst_bindatasetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
struct getdns_bindata *new_bindata = NULL;
|
struct getdns_bindata *new_bindata = NULL;
|
||||||
struct getdns_bindata *ans_bindata = NULL;
|
struct getdns_bindata *ans_bindata = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_bindatasetget");
|
tstmsg_case_begin("tst_bindatasetget");
|
||||||
|
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
|
|
||||||
/* test get function against empty list and with bogus params */
|
/* test get function against empty list and with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_bindata() empty list");
|
tstmsg_case_msg("getdns_list_get_bindata() empty list");
|
||||||
retval = getdns_list_get_bindata(NULL, index, &ans_bindata);
|
retval = getdns_list_get_bindata(NULL, index, &ans_bindata);
|
||||||
sprintf(msg, "getdns_list_get_bindata(NULL, index, &ans_bindata),retval = %d"
|
sprintf(msg,
|
||||||
, retval);
|
"getdns_list_get_bindata(NULL, index, &ans_bindata),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_bindata(list, index, NULL);
|
retval = getdns_list_get_bindata(list, index, NULL);
|
||||||
sprintf(msg, "getdns_list_get_bindata(list, index, NULL),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_bindata(list, index, NULL),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_bindata(list, 0, &ans_bindata)");
|
tstmsg_case_msg("getdns_list_get_bindata(list, 0, &ans_bindata)");
|
||||||
retval = getdns_list_get_bindata(list, 0, &ans_bindata);
|
retval = getdns_list_get_bindata(list, 0, &ans_bindata);
|
||||||
sprintf(msg, "getdns_list_get_bindata,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_bindata,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_bindata(list, 1, &ans_bindata)");
|
tstmsg_case_msg("getdns_list_get_bindata(list, 1, &ans_bindata)");
|
||||||
retval = getdns_list_get_bindata(list, 1, &ans_bindata);
|
retval = getdns_list_get_bindata(list, 1, &ans_bindata);
|
||||||
sprintf(msg, "getdns_list_get_bindata,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_bindata,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set function against empty list with bogus params */
|
/* test set function against empty list with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_bindata() empty list");
|
tstmsg_case_msg("getdns_list_set_bindata() empty list");
|
||||||
retval = getdns_list_set_bindata(NULL, index, NULL);
|
retval = getdns_list_set_bindata(NULL, index, NULL);
|
||||||
sprintf(msg, "getdns_list_set_bindata(NULL, index, ans_bindata),retval = %d", retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"getdns_list_set_bindata(NULL, index, ans_bindata),retval = %d",
|
||||||
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_bindata(list, 0, ans_bindata)");
|
tstmsg_case_msg("getdns_list_set_bindata(list, 0, ans_bindata)");
|
||||||
retval = getdns_list_set_bindata(list, 0, NULL);
|
retval = getdns_list_set_bindata(list, 0, NULL);
|
||||||
sprintf(msg, "getdns_list_set_bindata,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_bindata,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_bindata(list, 1, ans_bindata)");
|
tstmsg_case_msg("getdns_list_set_bindata(list, 1, ans_bindata)");
|
||||||
retval = getdns_list_set_bindata(list, 1, NULL);
|
retval = getdns_list_set_bindata(list, 1, NULL);
|
||||||
sprintf(msg, "getdns_list_set_bindata,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_bindata,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
new_bindata = (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
|
new_bindata =
|
||||||
new_bindata->size = strlen("foobar") + 1;
|
(struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
|
||||||
new_bindata->data = (uint8_t *) strdup("foobar");
|
new_bindata->size = strlen("foobar") + 1;
|
||||||
new_bindata->data[strlen("foobar")] = '\0';
|
new_bindata->data = (uint8_t *) strdup("foobar");
|
||||||
|
new_bindata->data[strlen("foobar")] = '\0';
|
||||||
|
|
||||||
getdns_list_add_item(list, &index);
|
getdns_list_add_item(list, &index);
|
||||||
getdns_list_set_bindata(list, index, new_bindata);
|
getdns_list_set_bindata(list, index, new_bindata);
|
||||||
retval = getdns_list_get_bindata(list, index, &ans_bindata);
|
retval = getdns_list_get_bindata(list, index, &ans_bindata);
|
||||||
sprintf(msg, "getdns_list_set/get_bindata,retval = %d, bindata->data = %d,%s"
|
sprintf(msg,
|
||||||
, retval, (int) ans_bindata->size, (char *) ans_bindata->data);
|
"getdns_list_set/get_bindata,retval = %d, bindata->data = %d,%s",
|
||||||
tstmsg_case_msg(msg);
|
retval, (int) ans_bindata->size, (char *) ans_bindata->data);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_bindatasetget */
|
} /* tst_bindatasetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_dictsetget */
|
/*---------------------------------------- tst_dictsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -123,74 +129,78 @@ tst_bindatasetget(void)
|
||||||
void
|
void
|
||||||
tst_dictsetget(void)
|
tst_dictsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
uint32_t ans_int;
|
uint32_t ans_int;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
struct getdns_dict *dict = NULL;
|
struct getdns_dict *dict = NULL;
|
||||||
struct getdns_dict *ansdict = NULL;
|
struct getdns_dict *ansdict = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_dictsetget");
|
tstmsg_case_begin("tst_dictsetget");
|
||||||
|
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
dict = getdns_dict_create();
|
dict = getdns_dict_create();
|
||||||
|
|
||||||
/* test dict get function against empty list and with bogus params */
|
/* test dict get function against empty list and with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_dict() empty list");
|
tstmsg_case_msg("getdns_list_get_dict() empty list");
|
||||||
retval = getdns_list_get_dict(NULL, index, &dict);
|
retval = getdns_list_get_dict(NULL, index, &dict);
|
||||||
sprintf(msg, "getdns_list_get_dict(NULL, index, &dict),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_dict(NULL, index, &dict),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_dict(list, index, NULL);
|
retval = getdns_list_get_dict(list, index, NULL);
|
||||||
sprintf(msg, "getdns_list_get_dict(list, index, NULL),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_dict(list, index, NULL),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_dict(list, 0, &dict)");
|
tstmsg_case_msg("getdns_list_get_dict(list, 0, &dict)");
|
||||||
retval = getdns_list_get_dict(list, 0, &dict);
|
retval = getdns_list_get_dict(list, 0, &dict);
|
||||||
sprintf(msg, "getdns_list_get_dict,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_dict,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_dict(list, 1, &dict)");
|
tstmsg_case_msg("getdns_list_get_dict(list, 1, &dict)");
|
||||||
retval = getdns_list_get_dict(list, 1, &dict);
|
retval = getdns_list_get_dict(list, 1, &dict);
|
||||||
sprintf(msg, "getdns_list_get_dict,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_dict,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test int set function against empty list with bogus params */
|
/* test int set function against empty list with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_dict() empty list");
|
tstmsg_case_msg("getdns_list_set_dict() empty list");
|
||||||
retval = getdns_list_set_dict(NULL, index, dict);
|
retval = getdns_list_set_dict(NULL, index, dict);
|
||||||
sprintf(msg, "getdns_list_set_dict(NULL, index, dict),retval = %d", retval);
|
sprintf(msg, "getdns_list_set_dict(NULL, index, dict),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_dict(list, 0, dict)");
|
tstmsg_case_msg("getdns_list_set_dict(list, 0, dict)");
|
||||||
retval = getdns_list_set_dict(list, 0, dict);
|
retval = getdns_list_set_dict(list, 0, dict);
|
||||||
sprintf(msg, "getdns_list_set_dict,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_dict,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_dict(list, 1, dict)");
|
tstmsg_case_msg("getdns_list_set_dict(list, 1, dict)");
|
||||||
retval = getdns_list_set_dict(list, 1, dict);
|
retval = getdns_list_set_dict(list, 1, dict);
|
||||||
sprintf(msg, "getdns_list_set_dict,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_dict,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
getdns_dict_set_int(dict, "foo", 42);
|
getdns_dict_set_int(dict, "foo", 42);
|
||||||
getdns_list_add_item(list, &index);
|
getdns_list_add_item(list, &index);
|
||||||
getdns_list_set_dict(list, index, dict);
|
getdns_list_set_dict(list, index, dict);
|
||||||
retval = getdns_list_get_dict(list, index, &ansdict);
|
retval = getdns_list_get_dict(list, index, &ansdict);
|
||||||
getdns_dict_get_int(ansdict, "foo", &ans_int);
|
getdns_dict_get_int(ansdict, "foo", &ans_int);
|
||||||
sprintf(msg, "getdns_list_set/get_dict,retval=%d, ans=%d", retval, ans_int);
|
sprintf(msg, "getdns_list_set/get_dict,retval=%d, ans=%d", retval,
|
||||||
tstmsg_case_msg(msg);
|
ans_int);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_dict_destroy(dict);
|
getdns_dict_destroy(dict);
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_dictsetget */
|
} /* tst_dictsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_listsetget */
|
/*---------------------------------------- tst_listsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -199,75 +209,80 @@ tst_dictsetget(void)
|
||||||
void
|
void
|
||||||
tst_listsetget(void)
|
tst_listsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
uint32_t ans_int;
|
uint32_t ans_int;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
struct getdns_list *new_list = NULL;
|
struct getdns_list *new_list = NULL;
|
||||||
struct getdns_list *ans_list = NULL;
|
struct getdns_list *ans_list = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_listsetget");
|
tstmsg_case_begin("tst_listsetget");
|
||||||
|
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
|
|
||||||
/* test get function against empty list and with bogus params */
|
/* test get function against empty list and with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_list() empty list");
|
tstmsg_case_msg("getdns_list_get_list() empty list");
|
||||||
retval = getdns_list_get_list(NULL, index, &ans_list);
|
retval = getdns_list_get_list(NULL, index, &ans_list);
|
||||||
sprintf(msg, "getdns_list_get_list(NULL, index, &ans_list),retval = %d", retval);
|
sprintf(msg,
|
||||||
tstmsg_case_msg(msg);
|
"getdns_list_get_list(NULL, index, &ans_list),retval = %d",
|
||||||
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_list(list, index, NULL);
|
retval = getdns_list_get_list(list, index, NULL);
|
||||||
sprintf(msg, "getdns_list_get_list(list, index, NULL),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_list(list, index, NULL),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_list(list, 0, &ans_list)");
|
tstmsg_case_msg("getdns_list_get_list(list, 0, &ans_list)");
|
||||||
retval = getdns_list_get_list(list, 0, &ans_list);
|
retval = getdns_list_get_list(list, 0, &ans_list);
|
||||||
sprintf(msg, "getdns_list_get_list,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_list,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_list(list, 1, &ans_list)");
|
tstmsg_case_msg("getdns_list_get_list(list, 1, &ans_list)");
|
||||||
retval = getdns_list_get_list(list, 1, &ans_list);
|
retval = getdns_list_get_list(list, 1, &ans_list);
|
||||||
sprintf(msg, "getdns_list_get_list,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_list,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set function against empty list with bogus params */
|
/* test set function against empty list with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_list() empty list");
|
tstmsg_case_msg("getdns_list_set_list() empty list");
|
||||||
retval = getdns_list_set_list(NULL, index, NULL);
|
retval = getdns_list_set_list(NULL, index, NULL);
|
||||||
sprintf(msg, "getdns_list_set_list(NULL, index, ans_list),retval = %d", retval);
|
sprintf(msg, "getdns_list_set_list(NULL, index, ans_list),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_list(list, 0, ans_list)");
|
tstmsg_case_msg("getdns_list_set_list(list, 0, ans_list)");
|
||||||
retval = getdns_list_set_list(list, 0, NULL);
|
retval = getdns_list_set_list(list, 0, NULL);
|
||||||
sprintf(msg, "getdns_list_set_list,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_list,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_list(list, 1, ans_list)");
|
tstmsg_case_msg("getdns_list_set_list(list, 1, ans_list)");
|
||||||
retval = getdns_list_set_list(list, 1, NULL);
|
retval = getdns_list_set_list(list, 1, NULL);
|
||||||
sprintf(msg, "getdns_list_set_list,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_list,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
new_list = getdns_list_create();
|
new_list = getdns_list_create();
|
||||||
getdns_list_add_item(new_list, &index);
|
getdns_list_add_item(new_list, &index);
|
||||||
getdns_list_set_int(new_list, index, 42);
|
getdns_list_set_int(new_list, index, 42);
|
||||||
|
|
||||||
getdns_list_add_item(list, &index);
|
getdns_list_add_item(list, &index);
|
||||||
getdns_list_set_list(list, index, new_list);
|
getdns_list_set_list(list, index, new_list);
|
||||||
retval = getdns_list_get_list(list, index, &ans_list);
|
retval = getdns_list_get_list(list, index, &ans_list);
|
||||||
getdns_list_get_int(ans_list, 0, &ans_int);
|
getdns_list_get_int(ans_list, 0, &ans_int);
|
||||||
sprintf(msg, "getdns_list_set/get_list,retval = %d, ans[0] = %d", retval, ans_int);
|
sprintf(msg, "getdns_list_set/get_list,retval = %d, ans[0] = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval, ans_int);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_listsetget */
|
} /* tst_listsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_intsetget */
|
/*---------------------------------------- tst_intsetget */
|
||||||
/**
|
/**
|
||||||
|
@ -276,68 +291,72 @@ tst_listsetget(void)
|
||||||
void
|
void
|
||||||
tst_intsetget(void)
|
tst_intsetget(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
uint32_t ans_int;
|
uint32_t ans_int;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
|
|
||||||
tstmsg_case_begin("tst_intsetget");
|
tstmsg_case_begin("tst_intsetget");
|
||||||
|
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
|
|
||||||
/* test int get function against empty list and with bogus params */
|
/* test int get function against empty list and with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_int() empty list");
|
tstmsg_case_msg("getdns_list_get_int() empty list");
|
||||||
retval = getdns_list_get_int(NULL, index, &ans_int);
|
retval = getdns_list_get_int(NULL, index, &ans_int);
|
||||||
sprintf(msg, "getdns_list_get_int(NULL, index, &ans_int),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_int(NULL, index, &ans_int),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_int(list, index, NULL);
|
retval = getdns_list_get_int(list, index, NULL);
|
||||||
sprintf(msg, "getdns_list_get_int(list, index, NULL),retval = %d", retval);
|
sprintf(msg, "getdns_list_get_int(list, index, NULL),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_int(list, 0, &ans_int)");
|
tstmsg_case_msg("getdns_list_get_int(list, 0, &ans_int)");
|
||||||
retval = getdns_list_get_int(list, 0, &ans_int);
|
retval = getdns_list_get_int(list, 0, &ans_int);
|
||||||
sprintf(msg, "getdns_list_get_int,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_int,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_int(list, 1, &ans_int)");
|
tstmsg_case_msg("getdns_list_get_int(list, 1, &ans_int)");
|
||||||
retval = getdns_list_get_int(list, 1, &ans_int);
|
retval = getdns_list_get_int(list, 1, &ans_int);
|
||||||
sprintf(msg, "getdns_list_get_int,retval = %d", retval);
|
sprintf(msg, "getdns_list_get_int,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test int set function against empty list with bogus params */
|
/* test int set function against empty list with bogus params */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_int() empty list");
|
tstmsg_case_msg("getdns_list_set_int() empty list");
|
||||||
retval = getdns_list_set_int(NULL, index, ans_int);
|
retval = getdns_list_set_int(NULL, index, ans_int);
|
||||||
sprintf(msg, "getdns_list_set_int(NULL, index, ans_int),retval = %d", retval);
|
sprintf(msg, "getdns_list_set_int(NULL, index, ans_int),retval = %d",
|
||||||
tstmsg_case_msg(msg);
|
retval);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_int(list, 0, ans_int)");
|
tstmsg_case_msg("getdns_list_set_int(list, 0, ans_int)");
|
||||||
retval = getdns_list_set_int(list, 0, ans_int);
|
retval = getdns_list_set_int(list, 0, ans_int);
|
||||||
sprintf(msg, "getdns_list_set_int,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_int,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_set_int(list, 1, ans_int)");
|
tstmsg_case_msg("getdns_list_set_int(list, 1, ans_int)");
|
||||||
retval = getdns_list_set_int(list, 1, ans_int);
|
retval = getdns_list_set_int(list, 1, ans_int);
|
||||||
sprintf(msg, "getdns_list_set_int,retval = %d", retval);
|
sprintf(msg, "getdns_list_set_int,retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
/* test set and get legitimate use case */
|
/* test set and get legitimate use case */
|
||||||
|
|
||||||
getdns_list_add_item(list, &index);
|
getdns_list_add_item(list, &index);
|
||||||
getdns_list_set_int(list, index, 42);
|
getdns_list_set_int(list, index, 42);
|
||||||
retval = getdns_list_get_int(list, index, &ans_int);
|
retval = getdns_list_get_int(list, index, &ans_int);
|
||||||
sprintf(msg, "getdns_list_set/get_int,retval = %d, ans = %d", retval, ans_int);
|
sprintf(msg, "getdns_list_set/get_int,retval = %d, ans = %d", retval,
|
||||||
tstmsg_case_msg(msg);
|
ans_int);
|
||||||
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_intsetget */
|
} /* tst_intsetget */
|
||||||
|
|
||||||
/*---------------------------------------- tst_create */
|
/*---------------------------------------- tst_create */
|
||||||
/**
|
/**
|
||||||
|
@ -346,75 +365,71 @@ tst_intsetget(void)
|
||||||
void
|
void
|
||||||
tst_create(void)
|
tst_create(void)
|
||||||
{
|
{
|
||||||
char msg[TSTMSGBUF];
|
char msg[TSTMSGBUF];
|
||||||
size_t index;
|
size_t index;
|
||||||
int i;
|
int i;
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
struct getdns_list *list = NULL;
|
struct getdns_list *list = NULL;
|
||||||
|
|
||||||
/* make sure we can do a simple create/destroy first */
|
/* make sure we can do a simple create/destroy first */
|
||||||
|
|
||||||
tstmsg_case_begin("tst_create");
|
tstmsg_case_begin("tst_create");
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_create");
|
tstmsg_case_msg("getdns_list_create");
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
|
|
||||||
if(list != NULL)
|
if (list != NULL) {
|
||||||
{
|
tstmsg_case_msg("getdns_list_destroy(list)");
|
||||||
tstmsg_case_msg("getdns_list_destroy(list)");
|
getdns_list_destroy(list);
|
||||||
getdns_list_destroy(list);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_destroy(NULL)");
|
tstmsg_case_msg("getdns_list_destroy(NULL)");
|
||||||
getdns_list_destroy(NULL);
|
getdns_list_destroy(NULL);
|
||||||
|
|
||||||
/* add items until we force it to allocate more storage */
|
/* add items until we force it to allocate more storage */
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_add_item(list) past block size");
|
tstmsg_case_msg("getdns_add_item(list) past block size");
|
||||||
list = getdns_list_create();
|
list = getdns_list_create();
|
||||||
for(i=0; i<GETDNS_LIST_BLOCKSZ+2; i++)
|
for (i = 0; i < GETDNS_LIST_BLOCKSZ + 2; i++) {
|
||||||
{
|
retval = getdns_list_add_item(list, &index);
|
||||||
retval = getdns_list_add_item(list, &index);
|
if (retval != GETDNS_RETURN_GOOD) {
|
||||||
if(retval != GETDNS_RETURN_GOOD)
|
sprintf(msg, "getdns_list_add_item,i=%d,retval = %d",
|
||||||
{
|
i, retval);
|
||||||
sprintf(msg, "getdns_list_add_item,i=%d,retval = %d", i, retval);
|
tstmsg_case_msg(msg);
|
||||||
tstmsg_case_msg(msg);
|
} else {
|
||||||
}
|
if (index != i) {
|
||||||
else
|
sprintf(msg,
|
||||||
{
|
"getdns_list_add_item,i=%d,index=%d,retval = %d",
|
||||||
if(index != i)
|
i, (int) index, retval);
|
||||||
{
|
tstmsg_case_msg(msg);
|
||||||
sprintf(msg, "getdns_list_add_item,i=%d,index=%d,retval = %d"
|
}
|
||||||
, i, (int) index, retval);
|
}
|
||||||
tstmsg_case_msg(msg);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_length(list)");
|
tstmsg_case_msg("getdns_list_get_length(list)");
|
||||||
retval = getdns_list_get_length(list, &index);
|
retval = getdns_list_get_length(list, &index);
|
||||||
sprintf(msg, "list length = %d", (int) index);
|
sprintf(msg, "list length = %d", (int) index);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
tstmsg_case_msg("getdns_list_get_length()");
|
tstmsg_case_msg("getdns_list_get_length()");
|
||||||
retval = getdns_list_get_length(NULL, &index);
|
retval = getdns_list_get_length(NULL, &index);
|
||||||
sprintf(msg, "NUll, &i, retval = %d", retval);
|
sprintf(msg, "NUll, &i, retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_length(NULL, NULL);
|
retval = getdns_list_get_length(NULL, NULL);
|
||||||
sprintf(msg, "NUll, NULL, retval = %d", retval);
|
sprintf(msg, "NUll, NULL, retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
retval = getdns_list_get_length(list, NULL);
|
retval = getdns_list_get_length(list, NULL);
|
||||||
sprintf(msg, "list, NULL, retval = %d", retval);
|
sprintf(msg, "list, NULL, retval = %d", retval);
|
||||||
tstmsg_case_msg(msg);
|
tstmsg_case_msg(msg);
|
||||||
|
|
||||||
getdns_list_destroy(list);
|
getdns_list_destroy(list);
|
||||||
|
|
||||||
tstmsg_case_end();
|
tstmsg_case_end();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} /* tst_create */
|
} /* tst_create */
|
||||||
|
|
||||||
/*---------------------------------------- main */
|
/*---------------------------------------- main */
|
||||||
/**
|
/**
|
||||||
|
@ -423,21 +438,21 @@ tst_create(void)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
tstmsg_prog_begin("tests_list");
|
tstmsg_prog_begin("tests_list");
|
||||||
|
|
||||||
tst_create();
|
tst_create();
|
||||||
|
|
||||||
tst_bindatasetget();
|
tst_bindatasetget();
|
||||||
|
|
||||||
tst_dictsetget();
|
tst_dictsetget();
|
||||||
|
|
||||||
tst_intsetget();
|
tst_intsetget();
|
||||||
|
|
||||||
tst_listsetget();
|
tst_listsetget();
|
||||||
|
|
||||||
tstmsg_prog_end();
|
tstmsg_prog_end();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* end tests_list.c */
|
/* end tests_list.c */
|
||||||
|
|
|
@ -34,23 +34,25 @@
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
|
|
||||||
/* Set up the callback function, which will also do the processing of the results */
|
/* Set up the callback function, which will also do the processing of the results */
|
||||||
void this_callbackfn(struct getdns_context_t *this_context,
|
void
|
||||||
uint16_t this_callback_type,
|
this_callbackfn(struct getdns_context_t *this_context,
|
||||||
struct getdns_dict *this_response,
|
uint16_t this_callback_type,
|
||||||
void *this_userarg,
|
struct getdns_dict *this_response,
|
||||||
getdns_transaction_t this_transaction_id)
|
void *this_userarg, getdns_transaction_t this_transaction_id)
|
||||||
{
|
{
|
||||||
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
|
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */
|
||||||
{
|
char *res = getdns_pretty_print_dict(this_response);
|
||||||
char* res = getdns_pretty_print_dict(this_response);
|
fprintf(stdout, "%s", res);
|
||||||
fprintf(stdout, "%s", res);
|
getdns_dict_destroy(this_response);
|
||||||
getdns_dict_destroy(this_response);
|
|
||||||
|
|
||||||
}
|
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
||||||
else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
fprintf(stderr,
|
||||||
fprintf(stderr, "The callback with ID %lld was cancelled. Exiting.", this_transaction_id);
|
"The callback with ID %lld was cancelled. Exiting.",
|
||||||
|
this_transaction_id);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "The callback got a callback_type of %d. Exiting.", this_callback_type);
|
fprintf(stderr,
|
||||||
|
"The callback got a callback_type of %d. Exiting.",
|
||||||
|
this_callback_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -58,46 +60,47 @@ main()
|
||||||
{
|
{
|
||||||
/* Create the DNS context for this call */
|
/* Create the DNS context for this call */
|
||||||
struct getdns_context_t *this_context = NULL;
|
struct getdns_context_t *this_context = NULL;
|
||||||
getdns_return_t context_create_return = getdns_context_create(&this_context, true);
|
getdns_return_t context_create_return =
|
||||||
if (context_create_return != GETDNS_RETURN_GOOD)
|
getdns_context_create(&this_context, true);
|
||||||
{
|
if (context_create_return != GETDNS_RETURN_GOOD) {
|
||||||
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
|
fprintf(stderr, "Trying to create the context failed: %d",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
context_create_return);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
||||||
|
|
||||||
getdns_context_set_timeout(this_context, 5000);
|
getdns_context_set_timeout(this_context, 5000);
|
||||||
/* Create an event base and put it in the context using the unknown function name */
|
/* Create an event base and put it in the context using the unknown function name */
|
||||||
struct event_base *this_event_base;
|
struct event_base *this_event_base;
|
||||||
this_event_base = event_base_new();
|
this_event_base = event_base_new();
|
||||||
if (this_event_base == NULL)
|
if (this_event_base == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Trying to create the event base failed.");
|
fprintf(stderr, "Trying to create the event base failed.");
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
(void)getdns_extension_set_libevent_base(this_context, this_event_base);
|
(void) getdns_extension_set_libevent_base(this_context,
|
||||||
|
this_event_base);
|
||||||
/* Set up the getdns call */
|
/* Set up the getdns call */
|
||||||
const char * this_name = "www.google.com";
|
const char *this_name = "www.google.com";
|
||||||
char* this_userarg = "somestring"; // Could add things here to help identify this call
|
char *this_userarg = "somestring"; // Could add things here to help identify this call
|
||||||
getdns_transaction_t this_transaction_id = 0;
|
getdns_transaction_t this_transaction_id = 0;
|
||||||
|
|
||||||
/* Make the call */
|
/* Make the call */
|
||||||
getdns_return_t dns_request_return = getdns_address(this_context, this_name,
|
getdns_return_t dns_request_return =
|
||||||
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
getdns_address(this_context, this_name,
|
||||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
||||||
{
|
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
|
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
this_name);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
// dns_request_return = getdns_service(this_context, this_name, NULL, this_userarg, &this_transaction_id,
|
// dns_request_return = getdns_service(this_context, this_name, NULL, this_userarg, &this_transaction_id,
|
||||||
// this_callbackfn);
|
// this_callbackfn);
|
||||||
// if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
// if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
|
||||||
// {
|
// {
|
||||||
// fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
|
// fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
|
||||||
// return(GETDNS_RETURN_GENERIC_ERROR);
|
// return(GETDNS_RETURN_GENERIC_ERROR);
|
||||||
// }
|
// }
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
/* Call the event loop */
|
/* Call the event loop */
|
||||||
event_base_dispatch(this_event_base);
|
event_base_dispatch(this_event_base);
|
||||||
// TODO: check the return value above
|
// TODO: check the return value above
|
||||||
|
@ -106,7 +109,6 @@ main()
|
||||||
getdns_context_destroy(this_context);
|
getdns_context_destroy(this_context);
|
||||||
/* Assuming we get here, leave gracefully */
|
/* Assuming we get here, leave gracefully */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* example-simple-answers.c */
|
/* example-simple-answers.c */
|
||||||
|
|
||||||
|
|
|
@ -32,50 +32,57 @@
|
||||||
#include "testmessages.h"
|
#include "testmessages.h"
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
|
|
||||||
static void print_response(getdns_dict* response) {
|
static void
|
||||||
char *dict_str = getdns_pretty_print_dict(response);
|
print_response(getdns_dict * response)
|
||||||
if (dict_str) {
|
{
|
||||||
fprintf(stdout, "The packet %s\n", dict_str);
|
char *dict_str = getdns_pretty_print_dict(response);
|
||||||
free(dict_str);
|
if (dict_str) {
|
||||||
}
|
fprintf(stdout, "The packet %s\n", dict_str);
|
||||||
|
free(dict_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
/* Create the DNS context for this call */
|
/* Create the DNS context for this call */
|
||||||
struct getdns_context_t *this_context = NULL;
|
struct getdns_context_t *this_context = NULL;
|
||||||
getdns_return_t context_create_return = getdns_context_create(&this_context, true);
|
getdns_return_t context_create_return =
|
||||||
if (context_create_return != GETDNS_RETURN_GOOD)
|
getdns_context_create(&this_context, true);
|
||||||
{
|
if (context_create_return != GETDNS_RETURN_GOOD) {
|
||||||
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
|
fprintf(stderr, "Trying to create the context failed: %d",
|
||||||
return(GETDNS_RETURN_GENERIC_ERROR);
|
context_create_return);
|
||||||
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB);
|
||||||
|
|
||||||
getdns_dict* response = NULL;
|
getdns_dict *response = NULL;
|
||||||
uint32_t responseLen = 0;
|
uint32_t responseLen = 0;
|
||||||
getdns_return_t ret = getdns_address_sync(this_context, "www.google.com", NULL, &responseLen, &response);
|
getdns_return_t ret =
|
||||||
|
getdns_address_sync(this_context, "www.google.com", NULL,
|
||||||
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
&responseLen, &response);
|
||||||
fprintf(stderr, "Address sync returned error.\n");
|
|
||||||
exit(EXIT_FAILURE);
|
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
||||||
}
|
fprintf(stderr, "Address sync returned error.\n");
|
||||||
print_response(response);
|
exit(EXIT_FAILURE);
|
||||||
getdns_dict_destroy(response);
|
}
|
||||||
|
print_response(response);
|
||||||
ret = getdns_service_sync(this_context, "www.google.com", NULL, &responseLen, &response);
|
getdns_dict_destroy(response);
|
||||||
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
|
||||||
fprintf(stderr, "Service sync returned error.\n");
|
ret =
|
||||||
exit(EXIT_FAILURE);
|
getdns_service_sync(this_context, "www.google.com", NULL,
|
||||||
}
|
&responseLen, &response);
|
||||||
print_response(response);
|
if (ret != GETDNS_RETURN_GOOD || response == NULL) {
|
||||||
getdns_dict_destroy(response);
|
fprintf(stderr, "Service sync returned error.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
/* Clean up */
|
}
|
||||||
|
print_response(response);
|
||||||
|
getdns_dict_destroy(response);
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
getdns_context_destroy(this_context);
|
getdns_context_destroy(this_context);
|
||||||
/* Assuming we get here, leave gracefully */
|
/* Assuming we get here, leave gracefully */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
/* example-simple-answers.c */
|
/* example-simple-answers.c */
|
||||||
|
|
||||||
|
|
|
@ -46,110 +46,109 @@ struct ub_ctx;
|
||||||
struct event;
|
struct event;
|
||||||
struct event_base;
|
struct event_base;
|
||||||
|
|
||||||
typedef enum network_req_state_enum {
|
typedef enum network_req_state_enum
|
||||||
NET_REQ_NOT_SENT,
|
{
|
||||||
NET_REQ_IN_FLIGHT,
|
NET_REQ_NOT_SENT,
|
||||||
NET_REQ_FINISHED,
|
NET_REQ_IN_FLIGHT,
|
||||||
NET_REQ_CANCELED
|
NET_REQ_FINISHED,
|
||||||
|
NET_REQ_CANCELED
|
||||||
} network_req_state;
|
} network_req_state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* structure used by validate_extensions() to check extension formats
|
* structure used by validate_extensions() to check extension formats
|
||||||
*/
|
*/
|
||||||
typedef struct getdns_extension_format {
|
typedef struct getdns_extension_format
|
||||||
char *extstring;
|
{
|
||||||
getdns_data_type exttype;
|
char *extstring;
|
||||||
|
getdns_data_type exttype;
|
||||||
} getdns_extension_format;
|
} getdns_extension_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request data for unbound
|
* Request data for unbound
|
||||||
**/
|
**/
|
||||||
typedef struct getdns_network_req {
|
typedef struct getdns_network_req
|
||||||
|
{
|
||||||
/* the async_id from unbound */
|
/* the async_id from unbound */
|
||||||
int unbound_id;
|
int unbound_id;
|
||||||
/* state var */
|
/* state var */
|
||||||
network_req_state state;
|
network_req_state state;
|
||||||
/* owner request (contains name) */
|
/* owner request (contains name) */
|
||||||
struct getdns_dns_req* owner;
|
struct getdns_dns_req *owner;
|
||||||
|
|
||||||
/* request type */
|
/* request type */
|
||||||
uint16_t request_type;
|
uint16_t request_type;
|
||||||
|
|
||||||
/* request class */
|
/* request class */
|
||||||
uint16_t request_class;
|
uint16_t request_class;
|
||||||
|
|
||||||
/* result */
|
/* result */
|
||||||
ldns_pkt* result;
|
ldns_pkt *result;
|
||||||
|
|
||||||
/* next request to issue after this one */
|
/* next request to issue after this one */
|
||||||
struct getdns_network_req* next;
|
struct getdns_network_req *next;
|
||||||
} getdns_network_req;
|
} getdns_network_req;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dns request - manages a number of network requests and
|
* dns request - manages a number of network requests and
|
||||||
* the initial data passed to getdns_general
|
* the initial data passed to getdns_general
|
||||||
*/
|
*/
|
||||||
typedef struct getdns_dns_req {
|
typedef struct getdns_dns_req
|
||||||
|
{
|
||||||
|
|
||||||
/* name */
|
/* name */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/* canceled flag */
|
/* canceled flag */
|
||||||
int canceled;
|
int canceled;
|
||||||
|
|
||||||
/* current network request */
|
/* current network request */
|
||||||
struct getdns_network_req *current_req;
|
struct getdns_network_req *current_req;
|
||||||
|
|
||||||
/* first request in list */
|
/* first request in list */
|
||||||
struct getdns_network_req *first_req;
|
struct getdns_network_req *first_req;
|
||||||
|
|
||||||
/* request timeout event */
|
/* request timeout event */
|
||||||
struct event* timeout;
|
struct event *timeout;
|
||||||
|
|
||||||
/* local callback timer */
|
/* local callback timer */
|
||||||
struct event* local_cb_timer;
|
struct event *local_cb_timer;
|
||||||
|
|
||||||
/* event base this req is scheduled on */
|
/* event base this req is scheduled on */
|
||||||
struct event_base* ev_base;
|
struct event_base *ev_base;
|
||||||
|
|
||||||
/* context that owns the request */
|
/* context that owns the request */
|
||||||
getdns_context_t context;
|
getdns_context_t context;
|
||||||
|
|
||||||
/* ub_ctx issuing the request */
|
/* ub_ctx issuing the request */
|
||||||
struct ub_ctx* unbound;
|
struct ub_ctx *unbound;
|
||||||
|
|
||||||
/* request extensions */
|
/* request extensions */
|
||||||
getdns_dict *extensions;
|
getdns_dict *extensions;
|
||||||
|
|
||||||
/* callback data */
|
/* callback data */
|
||||||
getdns_callback_t user_callback;
|
getdns_callback_t user_callback;
|
||||||
void *user_pointer;
|
void *user_pointer;
|
||||||
|
|
||||||
/* the transaction id */
|
/* the transaction id */
|
||||||
getdns_transaction_t trans_id;
|
getdns_transaction_t trans_id;
|
||||||
|
|
||||||
} getdns_dns_req;
|
} getdns_dns_req;
|
||||||
|
|
||||||
/* utility methods */
|
/* utility methods */
|
||||||
|
|
||||||
/* network request utilities */
|
/* network request utilities */
|
||||||
void network_req_free(getdns_network_req* net_req);
|
void network_req_free(getdns_network_req * net_req);
|
||||||
|
|
||||||
getdns_network_req* network_req_new(getdns_dns_req* owner,
|
|
||||||
uint16_t request_type,
|
|
||||||
uint16_t request_class,
|
|
||||||
struct getdns_dict* extensions);
|
|
||||||
|
|
||||||
|
getdns_network_req *network_req_new(getdns_dns_req * owner,
|
||||||
|
uint16_t request_type,
|
||||||
|
uint16_t request_class, struct getdns_dict *extensions);
|
||||||
|
|
||||||
/* dns request utils */
|
/* dns request utils */
|
||||||
getdns_dns_req* dns_req_new(getdns_context_t context,
|
getdns_dns_req *dns_req_new(getdns_context_t context,
|
||||||
struct ub_ctx* unbound,
|
struct ub_ctx *unbound,
|
||||||
const char* name,
|
const char *name, uint16_t request_type, struct getdns_dict *extensions);
|
||||||
uint16_t request_type,
|
|
||||||
struct getdns_dict *extensions);
|
|
||||||
|
|
||||||
|
void dns_req_free(getdns_dns_req * req);
|
||||||
void dns_req_free(getdns_dns_req* req);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,19 +44,21 @@
|
||||||
struct getdns_dns_req;
|
struct getdns_dns_req;
|
||||||
|
|
||||||
/* convert an ip address dict to a sock storage */
|
/* convert an ip address dict to a sock storage */
|
||||||
getdns_return_t dict_to_sockaddr(getdns_dict* ns, struct sockaddr_storage* output);
|
getdns_return_t dict_to_sockaddr(getdns_dict * ns,
|
||||||
getdns_return_t sockaddr_to_dict(struct sockaddr_storage* sockaddr, getdns_dict** output);
|
struct sockaddr_storage *output);
|
||||||
|
getdns_return_t sockaddr_to_dict(struct sockaddr_storage *sockaddr,
|
||||||
|
getdns_dict ** output);
|
||||||
|
|
||||||
getdns_dict *create_getdns_response(struct getdns_dns_req* completed_request);
|
getdns_dict *create_getdns_response(struct getdns_dns_req *completed_request);
|
||||||
|
|
||||||
/* dict util */
|
/* dict util */
|
||||||
/* set a string as bindata */
|
/* set a string as bindata */
|
||||||
getdns_return_t getdns_dict_util_set_string(getdns_dict* dict, char* name,
|
getdns_return_t getdns_dict_util_set_string(getdns_dict * dict, char *name,
|
||||||
const char* value);
|
const char *value);
|
||||||
|
|
||||||
/* get a string from a dict. result is valid as long as dict is valid */
|
/* get a string from a dict. result is valid as long as dict is valid */
|
||||||
getdns_return_t getdns_dict_util_get_string(getdns_dict* dict, char* name,
|
getdns_return_t getdns_dict_util_get_string(getdns_dict * dict, char *name,
|
||||||
char** result);
|
char **result);
|
||||||
char *reverse_address(char *addr_str);
|
char *reverse_address(char *addr_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +69,6 @@ char *reverse_address(char *addr_str);
|
||||||
* @return GETDNS_RETURN_NO_SUCH_EXTENSION A name in the extensions dict is not a valid extension.
|
* @return GETDNS_RETURN_NO_SUCH_EXTENSION A name in the extensions dict is not a valid extension.
|
||||||
* @return GETDNS_RETURN_EXTENSION_MISFORMAT One or more of the extensions has a bad format.
|
* @return GETDNS_RETURN_EXTENSION_MISFORMAT One or more of the extensions has a bad format.
|
||||||
*/
|
*/
|
||||||
getdns_return_t validate_extensions(getdns_dict *extensions);
|
getdns_return_t validate_extensions(getdns_dict * extensions);
|
||||||
|
|
||||||
/* util-internal.h */
|
/* util-internal.h */
|
||||||
|
|
|
@ -38,16 +38,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_validate_dnssec(
|
getdns_validate_dnssec(struct getdns_bindata * record_to_validate,
|
||||||
struct getdns_bindata *record_to_validate,
|
struct getdns_list * bundle_of_support_records,
|
||||||
struct getdns_list *bundle_of_support_records,
|
struct getdns_list * trust_anchor_rdatas)
|
||||||
struct getdns_list *trust_anchor_rdatas
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNUSED_PARAM(record_to_validate);
|
UNUSED_PARAM(record_to_validate);
|
||||||
UNUSED_PARAM(bundle_of_support_records);
|
UNUSED_PARAM(bundle_of_support_records);
|
||||||
UNUSED_PARAM(trust_anchor_rdatas);
|
UNUSED_PARAM(trust_anchor_rdatas);
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
} /* getdns_validate_dnssec */
|
} /* getdns_validate_dnssec */
|
||||||
|
|
||||||
/* getdns_validate_dnssec.c */
|
/* getdns_validate_dnssec.c */
|
||||||
|
|
Loading…
Reference in New Issue