3 * $Id: bres.h,v 1.2 1999/07/26 23:27:22 mdw Exp $
5 * Background reverse name resolution
7 * (c) 1999 Straylight/Edgeware
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.2 1999/07/26 23:27:22 mdw
33 * Change copyright notice.
35 * Revision 1.1.1.1 1999/07/01 08:56:23 mdw
47 /*----- Header files ------------------------------------------------------*/
49 #include <sys/types.h>
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
56 #include <mLib/selbuf.h>
58 /*----- Data structures ---------------------------------------------------*/
60 /* --- Client allocated request block --- */
62 typedef struct bres_client
{
63 struct bres_client
*next
, *prev
; /* Queue of waiting resolve jobs */
64 struct bres_server
*rs
; /* Pointer to attached server */
65 struct in_addr addr
; /* Address to be resolved */
66 void (*func
)(const char */
*host*/
, void */
*p*/
); /* Handler function */
67 void *p
; /* Argument for handler function */
70 /* --- Server maintained resolver blocks --- */
72 typedef struct bres_server
{
73 struct bres_server
*next
, *prev
; /* Doubly-linked list of servers */
74 pid_t kid
; /* Process id of server process */
75 selbuf b
; /* Input line-buffer selector */
76 sel_timer t
; /* Timeout for idle servers */
77 int fd
; /* File descriptor for writing */
78 struct bres_client
*rc
; /* Pointer to attached client */
81 /*----- Functions provided ------------------------------------------------*/
83 /* --- @bres_abort@ --- *
85 * Arguments: @bres_client *rc@ = pointer to client block
89 * Use: Removes a queued job.
92 extern void bres_abort(bres_client */
*rc*/
);
94 /* --- @bres_resolve@ --- *
96 * Arguments: @bres_client *rc@ = pointer to client block
97 * @struct in_addr addr@ = address to resolve
98 * @void (*func)(const char *host, void *p)@ = handler function
99 * @void *p@ = argument for handler function
103 * Use: Adds a resolver job to the queue. The job will be processed
104 * when there's a spare resolver process to deal with it.
107 extern void bres_resolve(bres_client */
*rc*/
, struct in_addr
/*addr*/,
108 void (*/
*func*/
)(const char */
*host*/
, void */
*p*/
),
111 /* --- @bres_init@ --- *
113 * Arguments: @sel_state *s@ = pointer to select multiplexor
117 * Use: Initializes the background resolver for use.
120 extern void bres_init(sel_state */
*s*/
);
122 /*----- That's all, folks -------------------------------------------------*/