Merge branch 'develop' of github.com:verisign/getdns into develop

This commit is contained in:
Willem Toorop 2014-01-13 15:32:35 +01:00
commit 1c4616bfb5
6 changed files with 67 additions and 32 deletions

View File

@ -1,9 +1,9 @@
/**
*
* getdns list management functions, note that the internal storage is
* getdns list management functions, note that the internal storage is
* accomplished via the libc binary search tree implementation so your
* pointer foo needs to be keen to digest some of the internal semantics
*
*
* Interfaces originally taken from the getdns API description pseudo implementation.
*
*/
@ -11,7 +11,7 @@
/*
* Copyright (c) 2013, Versign, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -107,7 +107,7 @@ getdns_dict_get_data_type(struct getdns_dict * dict, char *name,
struct getdns_dict_item *item;
if (!dict || !name || !answer)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
return GETDNS_RETURN_INVALID_PARAMETER;
item = getdns_dict_find(dict, name, 0);
if (!item)
@ -128,8 +128,11 @@ getdns_dict_get_dict(struct getdns_dict * dict, char *name,
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
item = getdns_dict_find(dict, name, 0);
if (!item || item->dtype != t_dict)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (!item)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (item->dtype != t_dict)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = item->data.dict;
return GETDNS_RETURN_GOOD;
@ -146,7 +149,10 @@ getdns_dict_get_list(struct getdns_dict * dict, char *name,
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
item = getdns_dict_find(dict, name, 0);
if (!item || item->dtype != t_list)
if (!item)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (item->dtype != t_list)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = item->data.list;
@ -164,7 +170,10 @@ getdns_dict_get_bindata(struct getdns_dict * dict, char *name,
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
item = getdns_dict_find(dict, name, 0);
if (!item || item->dtype != t_bindata)
if (!item)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (item->dtype != t_bindata)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = item->data.bindata;
@ -181,7 +190,10 @@ getdns_dict_get_int(struct getdns_dict * dict, char *name, uint32_t * answer)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
item = getdns_dict_find(dict, name, 0);
if (!item || item->dtype != t_int)
if (!item)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (item->dtype != t_int)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = item->data.n;
@ -370,8 +382,8 @@ getdns_dict_set_dict(struct getdns_dict * dict, char *name,
struct getdns_dict *newdict;
getdns_return_t retval;
if (!dict || !name)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (!dict || !name || !child_dict)
return GETDNS_RETURN_INVALID_PARAMETER;
retval = getdns_dict_copy(child_dict, &newdict);
if (retval != GETDNS_RETURN_GOOD)
@ -396,8 +408,8 @@ getdns_dict_set_list(struct getdns_dict * dict, char *name,
struct getdns_list *newlist;
getdns_return_t retval;
if (!dict || !name)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
if (!dict || !name || !child_list)
return GETDNS_RETURN_INVALID_PARAMETER;
retval = getdns_list_copy(child_list, &newlist);
if (retval != GETDNS_RETURN_GOOD)
@ -422,7 +434,7 @@ getdns_dict_set_bindata(struct getdns_dict * dict, char *name,
struct getdns_bindata *newbindata;
if (!dict || !name || !child_bindata)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
return GETDNS_RETURN_INVALID_PARAMETER;
newbindata = getdns_bindata_copy(&dict->mf, child_bindata);
if (!newbindata)
@ -446,7 +458,7 @@ getdns_dict_set_int(struct getdns_dict * dict, char *name,
struct getdns_dict_item *item;
if (!dict || !name)
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
return GETDNS_RETURN_INVALID_PARAMETER;
item = getdns_dict_find(dict, name, 1);
if (!item)
@ -459,7 +471,7 @@ getdns_dict_set_int(struct getdns_dict * dict, char *name,
/*---------------------------------------- getdns_pp_dict */
/**
* private function to help with indenting.
* private function to help with indenting.
* @param indent number of spaces to return
* @return a character string containing min(80, indent) spaces
*/

View File

@ -10,7 +10,7 @@
/*
* Copyright (c) 2013, Versign, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -196,7 +196,7 @@ ub_resolve_callback(void *arg, int err, ldns_buffer * result, int sec,
*/
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
* 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;
@ -329,13 +329,18 @@ getdns_general(struct getdns_context *context,
{
int extcheck = GETDNS_RETURN_GOOD;
if (!context || !context->event_base_async || callback == NULL) {
if (!context || !context->event_base_async) {
/* Can't do async without an event loop
* or callback
*/
return GETDNS_RETURN_BAD_CONTEXT;
}
/* ensure callback is not NULL */
if (!callback) {
return GETDNS_RETURN_INVALID_PARAMETER;
}
extcheck = validate_extensions(extensions);
if (extcheck != GETDNS_RETURN_GOOD)
return extcheck;

View File

@ -9,7 +9,7 @@
/*
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -74,6 +74,8 @@ struct event_base;
#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_MEMORY_ERROR 310
#define GETDNS_RETURN_MEMORY_ERROR_TEXT "Unable to allocate the memory required."
#define GETDNS_RETURN_INVALID_PARAMETER 311
#define GETDNS_RETURN_INVALID_PARAMETER_TEXT "A required parameter had an invalid value."
/** @}
*/

View File

@ -61,8 +61,11 @@ getdns_lookup_table getdns_error_str[] = {
{GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED,
"A query was made with a context that is using stub resolution and a DNSSEC extension specified."}
,
{GETDNS_RETURN_MEMORY_ERROR,
{GETDNS_RETURN_MEMORY_ERROR,
"Unable to allocate the memory required."}
,
{GETDNS_RETURN_INVALID_PARAMETER,
GETDNS_RETURN_INVALID_PARAMETER_TEXT }
,
{0, ""}
};

View File

@ -59,8 +59,8 @@ getdns_list_get_data_type(struct getdns_list * list, size_t index,
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (!answer)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
return GETDNS_RETURN_INVALID_PARAMETER;
*answer = list->items[index].dtype;
return GETDNS_RETURN_GOOD;
} /* getdns_list_get_data_type */
@ -73,7 +73,10 @@ getdns_list_get_dict(struct getdns_list * list, size_t index,
if (!list || index >= list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (!answer || list->items[index].dtype != t_dict)
if (!answer)
return GETDNS_RETURN_INVALID_PARAMETER;
if (list->items[index].dtype != t_dict)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = list->items[index].data.dict;
@ -89,7 +92,10 @@ getdns_list_get_list(struct getdns_list * list, size_t index,
if (!list || index >= list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (!answer || list->items[index].dtype != t_list)
if (!answer)
return GETDNS_RETURN_INVALID_PARAMETER;
if (list->items[index].dtype != t_list)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = list->items[index].data.list;
@ -104,7 +110,10 @@ getdns_list_get_bindata(struct getdns_list * list, size_t index,
if (!list || index >= list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (!answer || list->items[index].dtype != t_bindata)
if (!answer)
return GETDNS_RETURN_INVALID_PARAMETER;
if (list->items[index].dtype != t_bindata)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = list->items[index].data.bindata;
@ -118,7 +127,10 @@ getdns_list_get_int(struct getdns_list * list, size_t index, uint32_t * answer)
if (!list || index >= list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (!answer || list->items[index].dtype != t_int)
if (!answer)
return GETDNS_RETURN_INVALID_PARAMETER;
if (list->items[index].dtype != t_int)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
*answer = list->items[index].data.n;
@ -332,7 +344,7 @@ getdns_list_add_item(struct getdns_list *list, size_t * index)
getdns_return_t retval;
if (!list || !index)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
return GETDNS_RETURN_INVALID_PARAMETER;
if (list->numalloc == list->numinuse) {
retval = getdns_list_realloc(list);
@ -355,7 +367,7 @@ getdns_list_set_dict(struct getdns_list * list, size_t index,
getdns_return_t retval;
if (!list || !child_dict)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
return GETDNS_RETURN_INVALID_PARAMETER;
if (index > list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
@ -387,7 +399,7 @@ getdns_list_set_list(struct getdns_list * list, size_t index,
getdns_return_t retval;
if (!list || !child_list)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
return GETDNS_RETURN_INVALID_PARAMETER;
if (index > list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
@ -419,7 +431,7 @@ getdns_list_set_bindata(struct getdns_list * list, size_t index,
getdns_return_t retval;
if (!list || !child_bindata)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
return GETDNS_RETURN_INVALID_PARAMETER;
if (index > list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
@ -450,7 +462,7 @@ getdns_list_set_int(struct getdns_list * list, size_t index,
getdns_return_t retval;
if (!list)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
return GETDNS_RETURN_INVALID_PARAMETER;
if (index > list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;

View File

@ -70,6 +70,7 @@ getdns_general_sync(struct getdns_context *context,
{
getdns_return_t response_status;
RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
RETURN_IF_NULL(response, GETDNS_RETURN_INVALID_PARAMETER);
response_status = validate_extensions(extensions);
if (response_status == GETDNS_RETURN_GOOD) {
response_status = getdns_general_ub(context->unbound_sync,