2 * Routines for controlled update/initialization of request structures.
4 * request_init() initializes its argument. Pointers and string-valued members
5 * are initialized to zero, to indicate that no lookup has been attempted.
7 * request_set() adds information to an already initialized request structure.
9 * Both functions take a variable-length name-value list.
11 * Diagnostics are reported through syslog(3).
13 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
15 * $FreeBSD: src/contrib/tcp_wrappers/update.c,v 1.2 2000/02/03 10:27:00 shin Exp $
16 * $DragonFly: src/contrib/tcp_wrappers/update.c,v 1.2 2003/06/17 04:24:06 dillon Exp $
20 static char sccsid
[] = "@(#) update.c 1.1 94/12/28 17:42:56";
23 /* System libraries */
34 /* request_fill - request update engine */
36 static struct request_info
*request_fill(request
, ap
)
37 struct request_info
*request
;
43 while ((key
= va_arg(ap
, int)) > 0) {
46 tcpd_warn("request_fill: invalid key: %d", key
);
49 request
->fd
= va_arg(ap
, int);
53 request
->client
->sin
= va_arg(ap
, struct sockaddr
*);
55 request
->client
->sin
= va_arg(ap
, struct sockaddr_in
*);
60 request
->server
->sin
= va_arg(ap
, struct sockaddr
*);
62 request
->server
->sin
= va_arg(ap
, struct sockaddr_in
*);
67 * All other fields are strings with the same maximal length.
71 ptr
= request
->daemon
;
77 ptr
= request
->client
->name
;
80 ptr
= request
->client
->addr
;
83 ptr
= request
->server
->name
;
86 ptr
= request
->server
->addr
;
89 STRN_CPY(ptr
, va_arg(ap
, char *), STRING_LENGTH
);
94 /* request_init - initialize request structure */
96 struct request_info
*VARARGS(request_init
, struct request_info
*, request
)
98 static struct request_info default_info
;
99 struct request_info
*r
;
103 * Initialize data members. We do not assign default function pointer
104 * members, to avoid pulling in the whole socket module when it is not
107 VASTART(ap
, struct request_info
*, request
);
108 *request
= default_info
;
110 strcpy(request
->daemon
, unknown
);
111 sprintf(request
->pid
, "%d", getpid());
112 request
->client
->request
= request
;
113 request
->server
->request
= request
;
114 r
= request_fill(request
, ap
);
119 /* request_set - update request structure */
121 struct request_info
*VARARGS(request_set
, struct request_info
*, request
)
123 struct request_info
*r
;
126 VASTART(ap
, struct request_info
*, request
);
127 r
= request_fill(request
, ap
);