Commit 58ff88cc authored by Michael Graff's avatar Michael Graff
Browse files

use 'flags' rather than 'attributes' and rename pkt->flags to pkt->pktflags

parent 7193a176
......@@ -65,7 +65,7 @@ error_pkt_send(client_t *client, isc_uint32_t _result)
* for sending an error reply. This is a Good Thing.
*/
client->pkt.length = LWRES_LWPACKET_LENGTH;
client->pkt.flags |= LWRES_LWPACKETFLAG_RESPONSE;
client->pkt.pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
client->pkt.recvlength = LWRES_RECVLENGTH;
client->pkt.authtype = 0; /* XXXMLG */
client->pkt.authlength = 0;
......
......@@ -84,7 +84,7 @@ test_noop(void)
lwres_noopresponse_t noopresponse, *noopresponse2;
lwres_buffer_t b;
pkt.flags = 0;
pkt.pktflags = 0;
pkt.serial = 0x11223344;
pkt.recvlength = 0x55667788;
pkt.result = 0;
......@@ -119,7 +119,7 @@ test_noop(void)
b.base = NULL;
b.length = 0;
pkt.flags = 0;
pkt.pktflags = 0;
pkt.serial = 0x11223344;
pkt.recvlength = 0x55667788;
pkt.result = 0xdeadbeef;
......
......@@ -30,7 +30,7 @@ typedef struct lwres_lwpacket lwres_lwpacket_t;
struct lwres_lwpacket {
lwres_uint32_t length;
lwres_uint16_t version;
lwres_uint16_t flags;
lwres_uint16_t pktflags;
lwres_uint32_t serial;
lwres_uint32_t opcode;
lwres_uint32_t result;
......
......@@ -89,6 +89,29 @@
#define INADDR_LOOPBACK 0x7f000001UL
#endif
/*
* Flags.
*
* TRUST* define a two-bit value:
*
* TRUSTDEFAULT: Let the server decide what to do.
*
* TRUSTNOTREQUIRED: DNSSEC (or NIS equavalent) is not required.
*
* TRUSTREQUIRED: DNSSEC (if present) must validate, and the
* daemon the client is talking to must be DNSSEC aware.
*
* TRUSTRESERVED: No not used, reserved for future.
*
* XXXMLG -- currently not implemented!
*
*/
#define LWRES_FLAG_TRUSTDEFAULT 0x00000000U
#deifne LWRES_FLAG_TRUSTNOTREQUIRED 0x00000001U
#define LWRES_FLAG_TRUSTREQUIRED 0x00000010U
#define LWRES_FLAG_TRUSTRESERVED 0x00000011U
#define LWRES_FLAG_TRUSTMASK 0x00000011U /* mask for the above */
/*
* no-op
*/
......@@ -123,7 +146,7 @@ struct lwres_addr {
typedef struct {
/* public */
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint32_t addrtypes;
lwres_uint16_t namelen;
char *name;
......@@ -131,7 +154,7 @@ typedef struct {
typedef struct {
/* public */
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint16_t naliases;
lwres_uint16_t naddrs;
char *realname;
......@@ -150,13 +173,13 @@ typedef struct {
#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
typedef struct {
/* public */
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_addr_t addr;
} lwres_gnbarequest_t;
typedef struct {
/* public */
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint16_t naliases;
char *realname;
char **aliases;
......
......@@ -40,7 +40,7 @@ lwres_lwpacket_renderheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt)
lwres_buffer_putuint32(b, pkt->length);
lwres_buffer_putuint16(b, pkt->version);
lwres_buffer_putuint16(b, pkt->flags);
lwres_buffer_putuint16(b, pkt->pktflags);
lwres_buffer_putuint32(b, pkt->serial);
lwres_buffer_putuint32(b, pkt->opcode);
lwres_buffer_putuint32(b, pkt->result);
......@@ -67,7 +67,7 @@ lwres_lwpacket_parseheader(lwres_buffer_t *b, lwres_lwpacket_t *pkt)
if (pkt->length > space)
return (LWRES_R_UNEXPECTEDEND);
pkt->version = lwres_buffer_getuint16(b);
pkt->flags = lwres_buffer_getuint16(b);
pkt->pktflags = lwres_buffer_getuint16(b);
pkt->serial = lwres_buffer_getuint32(b);
pkt->opcode = lwres_buffer_getuint32(b);
pkt->result = lwres_buffer_getuint32(b);
......
......@@ -123,7 +123,7 @@ lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_GETADDRSBYNAME;
pkt->result = 0;
pkt->authtype = 0;
......@@ -139,9 +139,9 @@ lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req,
INSIST(SPACE_OK(b, payload_length));
/*
* Attributes.
* Flags.
*/
lwres_buffer_putuint32(b, req->attributes);
lwres_buffer_putuint32(b, req->flags);
/*
* Address types we'll accept.
......@@ -204,7 +204,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_GETADDRSBYNAME;
pkt->authtype = 0;
pkt->authlength = 0;
......@@ -221,8 +221,8 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req,
*/
INSIST(SPACE_OK(b, payload_length));
/* Attributes. */
lwres_buffer_putuint32(b, req->attributes);
/* Flags. */
lwres_buffer_putuint32(b, req->flags);
/* encode naliases and naddrs */
lwres_buffer_putuint16(b, req->naliases);
......@@ -266,7 +266,7 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
char *name;
lwres_gabnrequest_t *gabn;
lwres_uint32_t addrtypes;
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint16_t namelen;
REQUIRE(ctx != NULL);
......@@ -274,13 +274,13 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
REQUIRE(b != NULL);
REQUIRE(structp != NULL && *structp == NULL);
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
return (LWRES_R_FAILURE);
if (!SPACE_REMAINING(b, 4 + 4))
return (LWRES_R_UNEXPECTEDEND);
attributes = lwres_buffer_getuint32(b);
flags = lwres_buffer_getuint32(b);
addrtypes = lwres_buffer_getuint32(b);
/*
......@@ -297,7 +297,7 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
if (gabn == NULL)
return (LWRES_R_NOMEMORY);
gabn->attributes = attributes;
gabn->flags = flags;
gabn->addrtypes = addrtypes;
gabn->name = name;
gabn->namelen = namelen;
......@@ -312,7 +312,7 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
{
lwres_result_t ret;
unsigned int x;
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint16_t naliases;
lwres_uint16_t naddrs;
lwres_gabnresponse_t *gabn;
......@@ -326,7 +326,7 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
gabn = NULL;
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
return (LWRES_R_FAILURE);
/*
......@@ -334,7 +334,7 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
*/
if (!SPACE_REMAINING(b, 4 + 2 + 2))
return (LWRES_R_UNEXPECTEDEND);
attributes = lwres_buffer_getuint32(b);
flags = lwres_buffer_getuint32(b);
naliases = lwres_buffer_getuint16(b);
naddrs = lwres_buffer_getuint16(b);
......@@ -346,7 +346,7 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
LWRES_LIST_INIT(gabn->addrs);
gabn->base = NULL;
gabn->attributes = attributes;
gabn->flags = flags;
gabn->naliases = naliases;
gabn->naddrs = naddrs;
......
......@@ -56,7 +56,7 @@ lwres_gnbarequest_render(lwres_context_t *ctx, lwres_gnbarequest_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_GETNAMEBYADDR;
pkt->result = 0;
pkt->authtype = 0;
......@@ -75,7 +75,7 @@ lwres_gnbarequest_render(lwres_context_t *ctx, lwres_gnbarequest_t *req,
* Put the length and the data. We know this will fit because we
* just checked for it.
*/
lwres_buffer_putuint32(b, req->attributes);
lwres_buffer_putuint32(b, req->flags);
lwres_buffer_putuint32(b, req->addr.family);
lwres_buffer_putuint16(b, req->addr.length);
lwres_buffer_putmem(b, req->addr.address, req->addr.length);
......@@ -104,7 +104,7 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req,
/*
* Calculate packet size.
*/
payload_length = 4; /* attributes */
payload_length = 4; /* flags */
payload_length += 2; /* naliases */
payload_length += 2 + req->realnamelen + 1; /* real name encoding */
for (x = 0 ; x < req->naliases ; x++) /* each alias */
......@@ -118,7 +118,7 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_GETNAMEBYADDR;
pkt->authtype = 0;
pkt->authlength = 0;
......@@ -131,7 +131,7 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req,
}
INSIST(SPACE_OK(b, payload_length));
lwres_buffer_putuint32(b, req->attributes);
lwres_buffer_putuint32(b, req->flags);
/* encode naliases */
lwres_buffer_putuint16(b, req->naliases);
......@@ -167,7 +167,7 @@ lwres_gnbarequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
REQUIRE(b != NULL);
REQUIRE(structp != NULL && *structp == NULL);
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
return (LWRES_R_FAILURE);
gnba = CTXMALLOC(sizeof(lwres_gnbarequest_t));
......@@ -177,7 +177,7 @@ lwres_gnbarequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
if (!SPACE_REMAINING(b, 4))
return (LWRES_R_UNEXPECTEDEND);
gnba->attributes = lwres_buffer_getuint32(b);
gnba->flags = lwres_buffer_getuint32(b);
ret = lwres_addr_parse(b, &gnba->addr);
if (ret != LWRES_R_SUCCESS)
......@@ -204,7 +204,7 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
{
int ret;
unsigned int x;
lwres_uint32_t attributes;
lwres_uint32_t flags;
lwres_uint16_t naliases;
lwres_gnbaresponse_t *gnba;
......@@ -215,7 +215,7 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
gnba = NULL;
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
return (LWRES_R_FAILURE);
/*
......@@ -223,7 +223,7 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
*/
if (!SPACE_REMAINING(b, 4 + 2))
return (LWRES_R_UNEXPECTEDEND);
attributes = lwres_buffer_getuint32(b);
flags = lwres_buffer_getuint32(b);
naliases = lwres_buffer_getuint16(b);
gnba = CTXMALLOC(sizeof(lwres_gnbaresponse_t));
......@@ -233,7 +233,7 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
gnba->aliases = NULL;
gnba->aliaslen = NULL;
gnba->attributes = attributes;
gnba->flags = flags;
gnba->naliases = naliases;
if (naliases > 0) {
......
......@@ -53,7 +53,7 @@ lwres_nooprequest_render(lwres_context_t *ctx, lwres_nooprequest_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_NOOP;
pkt->result = 0;
pkt->authtype = 0;
......@@ -104,7 +104,7 @@ lwres_noopresponse_render(lwres_context_t *ctx, lwres_noopresponse_t *req,
pkt->length = buflen;
pkt->version = LWRES_LWPACKETVERSION_0;
pkt->flags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
pkt->opcode = LWRES_OPCODE_NOOP;
pkt->authtype = 0;
pkt->authlength = 0;
......@@ -142,7 +142,7 @@ lwres_nooprequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
REQUIRE(pkt != NULL);
REQUIRE(structp != NULL && *structp == NULL);
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) != 0)
return (LWRES_R_FAILURE);
req = CTXMALLOC(sizeof(lwres_nooprequest_t));
......@@ -189,7 +189,7 @@ lwres_noopresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
REQUIRE(pkt != NULL);
REQUIRE(structp != NULL && *structp == NULL);
if ((pkt->flags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
if ((pkt->pktflags & LWRES_LWPACKETFLAG_RESPONSE) == 0)
return (LWRES_R_FAILURE);
req = CTXMALLOC(sizeof(lwres_noopresponse_t));
......
......@@ -227,7 +227,7 @@ lwres_getaddrsbyname(lwres_context_t *ctx, const char *name,
request.addrtypes = addrtypes;
request.name = target_name;
request.namelen = target_length;
pkt.flags = 0;
pkt.pktflags = 0;
pkt.serial = serial;
pkt.result = 0;
pkt.recvlength = LWRES_RECVLENGTH;
......@@ -338,7 +338,7 @@ lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype,
request.addr.family = addrtype;
request.addr.length = addrlen;
memcpy(request.addr.address, addr, addrlen);
pkt.flags = 0;
pkt.pktflags = 0;
pkt.serial = serial;
pkt.result = 0;
pkt.recvlength = LWRES_RECVLENGTH;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment