mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 06:42:05 -04:00
add byaddr skeleton
This commit is contained in:
parent
0c32f6b044
commit
34347e0844
2 changed files with 216 additions and 0 deletions
88
lib/dns/byaddr.c
Normal file
88
lib/dns/byaddr.c
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C) 2000 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/mutex.h>
|
||||
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
/*
|
||||
* XXXRTH We could use a static event...
|
||||
*/
|
||||
|
||||
struct dns_byaddr {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_mutex_t lock;
|
||||
dns_view_t * view;
|
||||
/* Locked by lock. */
|
||||
dns_byaddrevent_t * event;
|
||||
};
|
||||
|
||||
#define BYADDR_MAGIC 0x42794164U /* ByAd. */
|
||||
#define VALID_BYADDR(b) ((b) != NULL && \
|
||||
(b)->magic == BYADDR_MAGIC)
|
||||
|
||||
#ifdef notyet
|
||||
|
||||
isc_result_t
|
||||
dns_byaddr_create(isc_netaddr_t *address, dns_view_t *view,
|
||||
unsigned int options, isc_task_t *task,
|
||||
isc_taskaction_t action, void *arg, dns_byaddr_t **byaddrp)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_byaddr_t *byaddr;
|
||||
|
||||
byaddr = isc_mem_get(view->mctx, sizeof *byaddr);
|
||||
if (byaddr == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
result = isc_mutex_init(&byaddr->lock);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_byaddr;
|
||||
byaddr->view = NULL;
|
||||
dns_view_attach(view, &byaddr->view);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_lock:
|
||||
isc_mutex_destroy(&byaddr->lock);
|
||||
|
||||
cleanup_byaddr:
|
||||
isc_mem_put(view->mctx, byaddr, sizeof *byaddr);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
dns_byaddr_cancel(dns_byaddr_t *byaddr) {
|
||||
}
|
||||
|
||||
void
|
||||
dns_byaddr_destroy(dns_byaddr_t **byaddrp) {
|
||||
}
|
||||
|
||||
#endif
|
||||
128
lib/dns/include/dns/byaddr.h
Normal file
128
lib/dns/include/dns/byaddr.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Copyright (C) 2000 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DNS_BYADDR_H
|
||||
#define DNS_BYADDR_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*
|
||||
* DNS ByAddr
|
||||
*
|
||||
* The byaddr module provides reverse lookup services for IPv4 and IPv6
|
||||
* addresses.
|
||||
*
|
||||
* MP:
|
||||
* The module ensures appropriate synchronization of data structures it
|
||||
* creates and manipulates.
|
||||
*
|
||||
* Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
* <TBS>
|
||||
*
|
||||
* Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* Standards:
|
||||
* RFCs: 1034, 1035, 2181, <TBS>
|
||||
* Drafts: <TBS>
|
||||
*/
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/netaddr.h>
|
||||
|
||||
#include <dns/types.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef struct dns_byaddrevent {
|
||||
ISC_EVENT_COMMON(struct dns_byaddrevent);
|
||||
dns_byaddr_t * byaddr;
|
||||
isc_result_t result;
|
||||
dns_fixedname_t name;
|
||||
} dns_byaddrevent_t;
|
||||
|
||||
isc_result_t
|
||||
dns_byaddr_create(isc_netaddr_t *address, dns_view_t *view,
|
||||
unsigned int options, isc_task_t *task,
|
||||
isc_taskaction_t action, void *arg, dns_byaddr_t **byaddrp);
|
||||
/*
|
||||
* Find the domain name of 'address'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* 'address' is a valid IPv4 or IPv6 address.
|
||||
*
|
||||
* 'view' is a valid view which has a resolver.
|
||||
*
|
||||
* 'task' is a valid task.
|
||||
*
|
||||
* byaddrp != NULL && *byaddrp == NULL
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* ISC_R_SUCCESS
|
||||
* ISC_R_NOMEMORY
|
||||
*
|
||||
* Any resolver-related error (e.g. ISC_R_SHUTTINGDOWN) may also be
|
||||
* returned.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_byaddr_cancel(dns_byaddr_t *byaddr);
|
||||
/*
|
||||
* Cancel 'byaddr'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* If 'byaddr' has not completed, post its BYADDRDONE event with a
|
||||
* result code of ISC_R_CANCELED.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* 'byaddr' is a valid byaddr.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_byaddr_destroy(dns_byaddr_t **byaddrp);
|
||||
/*
|
||||
* Destroy 'byaddr'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* '*byaddrp' is a valid byaddr.
|
||||
*
|
||||
* The caller has received the BYADDRDONE event (either because the
|
||||
* byaddr completed or because dns_byaddr_cancel() was called).
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
* *byaddrp == NULL.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* DNS_BYADDR_H */
|
||||
Loading…
Reference in a new issue