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 $
18 /* System libraries */
30 /* request_fill - request update engine */
32 static struct request_info
*request_fill(request
, ap
)
33 struct request_info
*request
;
39 while ((key
= va_arg(ap
, int)) > 0) {
42 tcpd_warn("request_fill: invalid key: %d", key
);
45 request
->fd
= va_arg(ap
, int);
49 request
->client
->sin
= va_arg(ap
, struct sockaddr
*);
51 request
->client
->sin
= va_arg(ap
, struct sockaddr_in
*);
56 request
->server
->sin
= va_arg(ap
, struct sockaddr
*);
58 request
->server
->sin
= va_arg(ap
, struct sockaddr_in
*);
63 * All other fields are strings with the same maximal length.
67 ptr
= request
->daemon
;
73 ptr
= request
->client
->name
;
76 ptr
= request
->client
->addr
;
79 ptr
= request
->server
->name
;
82 ptr
= request
->server
->addr
;
85 STRN_CPY(ptr
, va_arg(ap
, char *), STRING_LENGTH
);
90 /* request_init - initialize request structure */
92 struct request_info
*VARARGS(request_init
, struct request_info
*, request
)
94 static struct request_info default_info
;
95 struct request_info
*r
;
99 * Initialize data members. We do not assign default function pointer
100 * members, to avoid pulling in the whole socket module when it is not
103 VASTART(ap
, struct request_info
*, request
);
104 *request
= default_info
;
106 strcpy(request
->daemon
, unknown
);
107 sprintf(request
->pid
, "%d", getpid());
108 request
->client
->request
= request
;
109 request
->server
->request
= request
;
110 r
= request_fill(request
, ap
);
115 /* request_set - update request structure */
117 struct request_info
*VARARGS(request_set
, struct request_info
*, request
)
119 struct request_info
*r
;
122 VASTART(ap
, struct request_info
*, request
);
123 r
= request_fill(request
, ap
);