Commit 7a166c5c authored by Michael Graff's avatar Michael Graff
Browse files

completely decouple the lwres library from libisc. Bad michael for using...

completely decouple the lwres library from libisc.  Bad michael for using isc/int.h and isc/lang.h, bad Mark for adding isc/tring.h, isc/net.h, and a few others.
parent 628b3154
......@@ -161,6 +161,7 @@ struct dns_adbfind {
*
* _LAMEPRUNED:
* At least one address was omitted from the list because it was lame.
* This bit will NEVER be set if _RETURNLAME is set in the createfind().
*/
#define DNS_ADBFIND_INET 0x00000001
#define DNS_ADBFIND_INET6 0x00000002
......
......@@ -73,7 +73,7 @@ lwres_context_create(lwres_context_t **contextp, void *arg,
ctx->sock = -1;
ctx->timeout = LWRES_DEFAULT_TIMEOUT;
ctx->serial = (isc_uint32_t)ctx; /* XXXMLG */
ctx->serial = (lwres_uint32_t)ctx; /* XXXMLG */
(void)context_connect(ctx); /* XXXMLG */
......@@ -99,7 +99,7 @@ lwres_context_destroy(lwres_context_t **contextp)
CTXFREE(ctx, sizeof(lwres_context_t));
}
isc_uint32_t
lwres_uint32_t
lwres_context_nextserial(lwres_context_t *ctx)
{
REQUIRE(ctx != NULL);
......@@ -108,7 +108,7 @@ lwres_context_nextserial(lwres_context_t *ctx)
}
void
lwres_context_initserial(lwres_context_t *ctx, isc_uint32_t serial)
lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial)
{
REQUIRE(ctx != NULL);
......
......@@ -33,7 +33,7 @@
*/
struct lwres_context {
unsigned int timeout; /* time to wait for reply */
isc_uint32_t serial; /* serial number state */
lwres_uint32_t serial; /* serial number state */
/*
* For network I/O.
......
......@@ -3,20 +3,26 @@
* The Berkeley Software Design Inc. software License Agreement specifies
* the terms and conditions for redistribution.
*
* BSDI $Id: getaddrinfo.c,v 1.9 2000/02/01 06:55:36 marka Exp $
* BSDI $Id: getaddrinfo.c,v 1.10 2000/02/03 01:28:49 explorer Exp $
*/
#include <isc/net.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <lwres/lwres.h>
#include <lwres/netdb.h> /* XXX #include <netdb.h> */
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <string.h>
#include <errno.h>
#include <isc/string.h> /* need strsep */
#include <stdlib.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <arpa/inet.h>
#include <lwres/lwres.h>
#include <lwres/netdb.h> /* XXX #include <netdb.h> */
#define SA(addr) ((struct sockaddr *)(addr))
#define SIN(addr) ((struct sockaddr_in *)(addr))
......
......@@ -20,7 +20,8 @@ top_srcdir = @top_srcdir@
#
# Only list headers that are to be installed!
#
HEADERS = context.h lwbuffer.h lwpacket.h lwres.h netdb.h result.h
HEADERS = context.h lwbuffer.h lwpacket.h lwres.h netdb.h result.h \
int.h lang.h
SUBDIRS =
TARGETS =
......
......@@ -20,15 +20,15 @@
#include <stddef.h>
#include <isc/lang.h>
#include <isc/int.h>
#include <lwres/lang.h>
#include <lwres/int.h>
/*
* Used to set various options such as timeout, authentication, etc
*/
typedef struct lwres_context lwres_context_t;
ISC_LANG_BEGINDECLS
LWRES_LANG_BEGINDECLS
typedef void *(*lwres_malloc_t)(void *arg, size_t length);
typedef void (*lwres_free_t)(void *arg, void *mem, size_t length);
......@@ -65,11 +65,11 @@ lwres_context_destroy(lwres_context_t **contextp);
* contextp != NULL && contextp == NULL.
*/
isc_uint32_t
lwres_uint32_t
lwres_context_nextserial(lwres_context_t *ctx);
void
lwres_context_initserial(lwres_context_t *ctx, isc_uint32_t serial);
lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
void
lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
......@@ -83,7 +83,7 @@ lwres_context_sendrecv(lwres_context_t *ctx,
void *recvbase, int recvlen,
int *recvd_len);
ISC_LANG_ENDDECLS
LWRES_LANG_ENDDECLS
#endif /* LWRES_CONTEXT_H */
/*
* Copyright (C) 1999 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 LWRES_INT_H
#define LWRES_INT_H 1
#include <lwres/lang.h>
LWRES_LANG_BEGINDECLS
typedef char lwres_int8_t;
typedef unsigned char lwres_uint8_t;
typedef short lwres_int16_t;
typedef unsigned short lwres_uint16_t;
typedef int lwres_int32_t;
typedef unsigned int lwres_uint32_t;
typedef long long lwres_int64_t;
typedef unsigned long long lwres_uint64_t;
LWRES_LANG_ENDDECLS
#endif /* LWRES_INT_H */
/*
* Copyright (C) 1999 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 LWRES_LANG_H
#define LWRES_LANG_H 1
#ifdef __cplusplus
#define LWRES_LANG_BEGINDECLS extern "C" {
#define LWRES_LANG_ENDDECLS }
#else
#define LWRES_LANG_BEGINDECLS
#define LWRES_LANG_ENDDECLS
#endif
#endif /* LWRES_LANG_H */
......@@ -101,10 +101,10 @@
*** Imports
***/
#include <isc/lang.h>
#include <isc/int.h>
#include <lwres/lang.h>
#include <lwres/int.h>
ISC_LANG_BEGINDECLS
LWRES_LANG_BEGINDECLS
/***
*** Magic numbers
......@@ -262,7 +262,7 @@ lwres_buffer_back(lwres_buffer_t *b, unsigned int n);
*
*/
isc_uint8_t
lwres_uint8_t
lwres_buffer_getuint8(lwres_buffer_t *b);
/*
* Read an unsigned 8-bit integer from 'b' and return it.
......@@ -283,7 +283,7 @@ lwres_buffer_getuint8(lwres_buffer_t *b);
*/
void
lwres_buffer_putuint8(lwres_buffer_t *b, isc_uint8_t val);
lwres_buffer_putuint8(lwres_buffer_t *b, lwres_uint8_t val);
/*
* Store an unsigned 8-bit integer from 'val' into 'b'.
*
......@@ -296,7 +296,7 @@ lwres_buffer_putuint8(lwres_buffer_t *b, isc_uint8_t val);
* The used pointer in 'b' is advanced by 1.
*/
isc_uint16_t
lwres_uint16_t
lwres_buffer_getuint16(lwres_buffer_t *b);
/*
* Read an unsigned 16-bit integer in network byte order from 'b', convert
......@@ -318,7 +318,7 @@ lwres_buffer_getuint16(lwres_buffer_t *b);
*/
void
lwres_buffer_putuint16(lwres_buffer_t *b, isc_uint16_t val);
lwres_buffer_putuint16(lwres_buffer_t *b, lwres_uint16_t val);
/*
* Store an unsigned 16-bit integer in host byte order from 'val'
* into 'b' in network byte order.
......@@ -332,7 +332,7 @@ lwres_buffer_putuint16(lwres_buffer_t *b, isc_uint16_t val);
* The used pointer in 'b' is advanced by 2.
*/
isc_uint32_t
lwres_uint32_t
lwres_buffer_getuint32(lwres_buffer_t *b);
/*
* Read an unsigned 32-bit integer in network byte order from 'b', convert
......@@ -354,7 +354,7 @@ lwres_buffer_getuint32(lwres_buffer_t *b);
*/
void
lwres_buffer_putuint32(lwres_buffer_t *b, isc_uint32_t val);
lwres_buffer_putuint32(lwres_buffer_t *b, lwres_uint32_t val);
/*
* Store an unsigned 32-bit integer in host byte order from 'val'
* into 'b' in network byte order.
......@@ -380,6 +380,6 @@ lwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base, unsigned int l
*
*/
ISC_LANG_ENDDECLS
LWRES_LANG_ENDDECLS
#endif /* LWRES_BUFFER_H */
......@@ -20,23 +20,23 @@
#include <stddef.h>
#include <isc/lang.h>
#include <isc/int.h>
#include <lwres/lang.h>
#include <lwres/int.h>
#include <lwres/lwbuffer.h>
typedef struct lwres_lwpacket lwres_lwpacket_t;
struct lwres_lwpacket {
isc_uint32_t length;
isc_uint16_t version;
isc_uint16_t flags;
isc_uint32_t serial;
isc_uint32_t opcode;
isc_uint32_t result;
isc_uint32_t recvlength;
isc_uint16_t authtype;
isc_uint16_t authlength;
lwres_uint32_t length;
lwres_uint16_t version;
lwres_uint16_t flags;
lwres_uint32_t serial;
lwres_uint32_t opcode;
lwres_uint32_t result;
lwres_uint32_t recvlength;
lwres_uint16_t authtype;
lwres_uint16_t authlength;
};
#define LWRES_LWPACKET_LENGTH (4 * 5 + 2 * 4)
......@@ -113,7 +113,7 @@ struct lwres_lwpacket {
* NS, SOA, etc. using this opcode.
*/
ISC_LANG_BEGINDECLS
LWRES_LANG_BEGINDECLS
int
lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt);
......@@ -121,6 +121,6 @@ lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt);
int
lwres_lwpacket_parseheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt);
ISC_LANG_ENDDECLS
LWRES_LANG_ENDDECLS
#endif /* LWRES_LWPACKET_H */
......@@ -20,8 +20,8 @@
#include <stddef.h>
#include <isc/lang.h>
#include <isc/int.h>
#include <lwres/lang.h>
#include <lwres/int.h>
#include <lwres/context.h>
#include <lwres/lwpacket.h>
......@@ -101,13 +101,13 @@
typedef struct {
/* public */
isc_uint16_t datalength;
lwres_uint16_t datalength;
unsigned char *data;
} lwres_nooprequest_t;
typedef struct {
/* public */
isc_uint16_t datalength;
lwres_uint16_t datalength;
unsigned char *data;
} lwres_noopresponse_t;
......@@ -117,26 +117,26 @@ typedef struct {
#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
typedef struct {
isc_uint32_t family;
isc_uint16_t length;
lwres_uint32_t family;
lwres_uint16_t length;
const unsigned char *address;
} lwres_addr_t;
typedef struct {
/* public */
isc_uint32_t addrtypes;
isc_uint16_t namelen;
lwres_uint32_t addrtypes;
lwres_uint16_t namelen;
char *name;
} lwres_gabnrequest_t;
typedef struct {
/* public */
isc_uint16_t naliases;
isc_uint16_t naddrs;
lwres_uint16_t naliases;
lwres_uint16_t naddrs;
char *realname;
char **aliases;
isc_uint16_t realnamelen;
isc_uint16_t *aliaslen;
lwres_uint16_t realnamelen;
lwres_uint16_t *aliaslen;
lwres_addr_t *addrs;
/* if base != NULL, it will be freed when this structure is freed. */
void *base;
......@@ -154,11 +154,11 @@ typedef struct {
typedef struct {
/* public */
isc_uint16_t naliases;
lwres_uint16_t naliases;
char *realname;
char **aliases;
isc_uint16_t realnamelen;
isc_uint16_t *aliaslen;
lwres_uint16_t realnamelen;
lwres_uint16_t *aliaslen;
/* if base != NULL, it will be freed when this structure is freed. */
void *base;
size_t baselen;
......@@ -170,7 +170,7 @@ typedef struct {
#define LWRES_MAX_ALIASES 8 /* max # of aliases */
#define LWRES_MAX_ADDRS 32 /* max # of addrs */
ISC_LANG_BEGINDECLS
LWRES_LANG_BEGINDECLS
int
lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req,
......@@ -356,20 +356,20 @@ lwres_noopresponse_free(lwres_context_t *ctx, lwres_noopresponse_t **structp);
*/
int
lwres_string_parse(lwres_buffer_t *b, char **c, isc_uint16_t *len);
lwres_string_parse(lwres_buffer_t *b, char **c, lwres_uint16_t *len);
int
lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
int
lwres_getaddrsbyname(lwres_context_t *ctx, const char *name,
isc_uint32_t addrtypes, lwres_gabnresponse_t **structp);
lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);
int
lwres_getnamebyaddr(lwres_context_t *ctx, isc_uint32_t addrtype,
isc_uint16_t addrlen, const unsigned char *addr,
lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype,
lwres_uint16_t addrlen, const unsigned char *addr,
lwres_gnbaresponse_t **structp);
ISC_LANG_ENDDECLS
LWRES_LANG_ENDDECLS
#endif /* LWRES_LWRES_H */
......@@ -15,8 +15,8 @@
* SOFTWARE.
*/
#ifndef lwres_netdb_h
#define lwres_netdb_h 1
#ifndef LWRES_NETDB_H
#define LWRES_NETDB_H 1
/*
* ++Copyright++ 1980, 1983, 1988, 1993
......@@ -106,12 +106,14 @@
/*
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
* $Id: netdb.h.in,v 1.10 2000/01/27 13:04:15 marka Exp $
* $Id: netdb.h.in,v 1.11 2000/02/03 01:28:52 explorer Exp $
*/
#include <stdio.h>
#include <isc/net.h>
#include <isc/lang.h>
#if 0
#include <lwres/net.h>
#endif
#include <lwres/lang.h>
#ifndef _PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
......
......@@ -18,6 +18,13 @@
#ifndef LWRES_RESULT_H
#define LWRES_RESULT_H 1
/*
* XXXMLG
* should be unsigned when functions are fixed to return a status, not both
* a status and an FD or whatever.
*/
typedef int lwres_result_t;
#define LWRES_R_SUCCESS 0
#define LWRES_R_NOMEMORY -1
#define LWRES_R_TIMEOUT -2
......
......@@ -140,11 +140,11 @@ lwres_buffer_back(lwres_buffer_t *b, unsigned int n)
b->current -= n;
}
isc_uint8_t
lwres_uint8_t
lwres_buffer_getuint8(lwres_buffer_t *b)
{
unsigned char *cp;
isc_uint8_t result;
lwres_uint8_t result;
/*
* Read an unsigned 8-bit integer from 'b' and return it.
......@@ -162,7 +162,7 @@ lwres_buffer_getuint8(lwres_buffer_t *b)
}
void
lwres_buffer_putuint8(lwres_buffer_t *b, isc_uint8_t val)
lwres_buffer_putuint8(lwres_buffer_t *b, lwres_uint8_t val)
{
unsigned char *cp;
......@@ -175,11 +175,11 @@ lwres_buffer_putuint8(lwres_buffer_t *b, isc_uint8_t val)
cp[0] = (val & 0x00ff);
}
isc_uint16_t
lwres_uint16_t
lwres_buffer_getuint16(lwres_buffer_t *b)
{
unsigned char *cp;
isc_uint16_t result;
lwres_uint16_t result;
/*
* Read an unsigned 16-bit integer in network byte order from 'b',
......@@ -199,7 +199,7 @@ lwres_buffer_getuint16(lwres_buffer_t *b)
}
void
lwres_buffer_putuint16(lwres_buffer_t *b, isc_uint16_t val)
lwres_buffer_putuint16(lwres_buffer_t *b, lwres_uint16_t val)
{
unsigned char *cp;
......@@ -213,11 +213,11 @@ lwres_buffer_putuint16(lwres_buffer_t *b, isc_uint16_t val)
cp[1] = (val & 0x00ff);
}
isc_uint32_t
lwres_uint32_t
lwres_buffer_getuint32(lwres_buffer_t *b)
{
unsigned char *cp;
isc_uint32_t result;
lwres_uint32_t result;
/*
* Read an unsigned 32-bit integer in network byte order from 'b',
......@@ -239,7 +239,7 @@ lwres_buffer_getuint32(lwres_buffer_t *b)
}
void
lwres_buffer_putuint32(lwres_buffer_t *b, isc_uint32_t val)
lwres_buffer_putuint32(lwres_buffer_t *b, lwres_uint32_t val)
{
unsigned char *cp;
......
......@@ -27,7 +27,7 @@
#include "assert_p.h"
#define LWPACKET_LENGTH (sizeof(isc_uint16_t) * 4 + sizeof(isc_uint32_t) * 5)
#define LWPACKET_LENGTH (sizeof(lwres_uint16_t) * 4 + sizeof(lwres_uint32_t) * 5)
int
lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt)
......@@ -54,7 +54,7 @@ lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt)
int
lwres_lwpacket_parseheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt)
{
isc_uint32_t space;
lwres_uint32_t space;
REQUIRE(b != NULL);
REQUIRE(pkt != NULL);
......
......@@ -37,7 +37,7 @@ lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req,
size_t buflen;
int ret;
size_t payload_length;
isc_uint16_t datalen;
lwres_uint16_t datalen;
REQUIRE(ctx != NULL);
REQUIRE(req != NULL);
......@@ -99,7 +99,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
size_t buflen;
int ret;
size_t payload_length;
isc_uint16_t datalen;
lwres_uint16_t datalen;
int x;
REQUIRE(ctx != NULL);
......@@ -108,7 +108,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
REQUIRE(b != NULL);
/* naliases, naddrs */
payload_length = sizeof(isc_uint16_t) * 2;
payload_length = sizeof(lwres_uint16_t) * 2;
/* real name encoding */
payload_length += 2 + req->realnamelen + 1;
/* each alias */
......@@ -116,7 +116,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
payload_length += 2 + req->aliaslen[x] + 1;
/* each address */
for (x = 0 ; x < req->naddrs ; x++) {
payload_length += sizeof(isc_uint32_t) + sizeof(isc_uint16_t);
payload_length += sizeof(lwres_uint32_t) + sizeof(lwres_uint16_t);
payload_length += req->addrs[x].length;
}
......@@ -142,7 +142,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
/* encode naliases and naddrs */
INSIST(SPACE_OK(b, sizeof(isc_uint16_t) * 2));
INSIST(SPACE_OK(b, sizeof(lwres_uint16_t) * 2));
lwres_buffer_putuint16(b, req->naliases);
lwres_buffer_putuint16(b, req->naddrs);
......@@ -164,8 +164,8 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
/* encode the addresses */
for (x = 0 ; x < req->naddrs ; x++) {
datalen = req->addrs[x].length + sizeof(isc_uint16_t)
+ sizeof(isc_uint32_t);
datalen = req->addrs[x].length + sizeof(lwres_uint16_t)
+ sizeof(lwres_uint32_t);
INSIST(SPACE_OK(b, datalen));
lwres_buffer_putuint32(b, req->addrs[x].family);
lwres_buffer_putuint16(b, req->addrs[x].length);
......@@ -186,8 +186,8 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
int ret;
char *name;
lwres_gabnrequest_t *gabn;
isc_uint32_t addrtypes;
isc_uint16_t namelen;
lwres_uint32_t addrtypes;
lwres_uint16_t namelen;
REQUIRE(ctx != NULL);
REQUIRE(pkt != NULL);
......@@ -230,8 +230,8 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
{
int ret;
unsigned int x;
isc_uint16_t naliases;
isc_uint16_t naddrs;
lwres_uint16_t nalias