3 * $Id: bres.h,v 1.1 1999/07/01 08:56:23 mdw Exp $
5 * Background reverse name resolution
7 * (c) 1999 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the `fw' port forwarder.
14 * `fw' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `fw' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `fw'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1999/07/01 08:56:23 mdw
44 /*----- Header files ------------------------------------------------------*/
46 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
53 #include <mLib/selbuf.h>
55 /*----- Data structures ---------------------------------------------------*/
57 /* --- Client allocated request block --- */
59 typedef struct bres_client
{
60 struct bres_client
*next
, *prev
; /* Queue of waiting resolve jobs */
61 struct bres_server
*rs
; /* Pointer to attached server */
62 struct in_addr addr
; /* Address to be resolved */
63 void (*func
)(const char */
*host*/
, void */
*p*/
); /* Handler function */
64 void *p
; /* Argument for handler function */
67 /* --- Server maintained resolver blocks --- */
69 typedef struct bres_server
{
70 struct bres_server
*next
, *prev
; /* Doubly-linked list of servers */
71 pid_t kid
; /* Process id of server process */
72 selbuf b
; /* Input line-buffer selector */
73 sel_timer t
; /* Timeout for idle servers */
74 int fd
; /* File descriptor for writing */
75 struct bres_client
*rc
; /* Pointer to attached client */
78 /*----- Functions provided ------------------------------------------------*/
80 /* --- @bres_abort@ --- *
82 * Arguments: @bres_client *rc@ = pointer to client block
86 * Use: Removes a queued job.
89 extern void bres_abort(bres_client */
*rc*/
);
91 /* --- @bres_resolve@ --- *
93 * Arguments: @bres_client *rc@ = pointer to client block
94 * @struct in_addr addr@ = address to resolve
95 * @void (*func)(const char *host, void *p)@ = handler function
96 * @void *p@ = argument for handler function
100 * Use: Adds a resolver job to the queue. The job will be processed
101 * when there's a spare resolver process to deal with it.
104 extern void bres_resolve(bres_client */
*rc*/
, struct in_addr
/*addr*/,
105 void (*/
*func*/
)(const char */
*host*/
, void */
*p*/
),
108 /* --- @bres_init@ --- *
110 * Arguments: @sel_state *s@ = pointer to select multiplexor
114 * Use: Initializes the background resolver for use.
117 extern void bres_init(sel_state */
*s*/
);
119 /*----- That's all, folks -------------------------------------------------*/