client.h revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
/*
* 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.
*/
/* $Id: client.h,v 1.18 2000/08/01 01:11:31 tale Exp $ */
#ifndef LWD_CLIENT_H
#define LWD_CLIENT_H 1
#include <isc/eventclass.h>
#include <isc/sockaddr.h>
#include <dns/fixedname.h>
typedef struct clientmgr_s clientmgr_t;
struct client_s {
unsigned int state;
void *arg; /* packet processing state */
/*
* Received data info.
*/
/*
* Send data state. If sendbuf != buffer (that is, the send buffer
* isn't our receive buffer) it will be freed to the lwres_context_t.
*/
unsigned char *sendbuf;
/*
* gabn (get address by name) state info.
*/
unsigned int find_wanted; /* Addresses we want */
/*
* gnba (get name by address) state info.
*/
unsigned int options;
/*
* structures eventually.
*
* XXXMLG We can keep all of this in a client since we only service
* three packet types right now. If we started handling more,
*/
char *aliases[LWRES_MAX_ALIASES];
};
/*
* Client states.
*
* _IDLE The client is not doing anything at all.
*
* _RECV The client is waiting for data after issuing a socket recv().
*
* _RECVDONE Data has been received, and is being processed.
*
* _FINDWAIT An adb (or other) request was made that cannot be satisfied
* immediately. An event will wake the client up.
*
* _SEND All data for a response has completed, and a reply was
* sent via a socket send() call.
*
* Badly formatted state table:
*
* IDLE -> RECV when client has a recv() queued.
*
* RECV -> RECVDONE when recvdone event received.
*
* RECVDONE -> SEND if the data for a reply is at hand.
* RECVDONE -> FINDWAIT if more searching is needed, and events will
* eventually wake us up again.
*
* FINDWAIT -> SEND when enough data was received to reply.
*
* SEND -> IDLE when a senddone event was received.
*
* At any time -> IDLE on error. Sometimes this will be -> SEND
* instead, if enough data is on hand to reply with a meaningful
* error.
*
* Packets which are badly formatted may or may not get error returns.
*/
#define CLIENT_STATE_IDLE 1
#define CLIENT_STATE_RECV 2
#define CLIENT_STATE_RECVDONE 3
#define CLIENT_STATE_FINDWAIT 4
#define CLIENT_STATE_SEND 5
#define CLIENT_STATE_SENDDONE 6
/*
* Overall magic test that means we're not idle.
*/
#define CLIENT_ISRUNNING(c) (!CLIENT_ISIDLE(c))
struct clientmgr_s {
unsigned int flags;
};
#define CLIENTMGR_FLAG_RECVPENDING 0x00000001
#define CLIENTMGR_FLAG_SHUTTINGDOWN 0x00000002
void client_state_idle(client_t *);
/*
* Processing functions of various types.
*/
void client_init_aliases(client_t *);
void client_init_gabn(client_t *);
void client_init_gnba(client_t *);
#endif /* LWD_CLIENT_H */