2 a596b957 2022-07-14 tracey * Copyright (c) 2020-2022 Tracey Emery <tracey@traceyemery.net>
3 a596b957 2022-07-14 tracey * Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
4 a596b957 2022-07-14 tracey * Copyright (c) 2013 Florian Obser <florian@openbsd.org>
6 a596b957 2022-07-14 tracey * Permission to use, copy, modify, and distribute this software for any
7 a596b957 2022-07-14 tracey * purpose with or without fee is hereby granted, provided that the above
8 a596b957 2022-07-14 tracey * copyright notice and this permission notice appear in all copies.
10 a596b957 2022-07-14 tracey * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 a596b957 2022-07-14 tracey * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 a596b957 2022-07-14 tracey * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 a596b957 2022-07-14 tracey * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 a596b957 2022-07-14 tracey * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 a596b957 2022-07-14 tracey * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 a596b957 2022-07-14 tracey * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 a596b957 2022-07-14 tracey #include <arpa/inet.h>
20 a596b957 2022-07-14 tracey #include <sys/queue.h>
21 a596b957 2022-07-14 tracey #include <sys/socket.h>
22 a596b957 2022-07-14 tracey #include <sys/types.h>
24 a596b957 2022-07-14 tracey #include <errno.h>
25 a596b957 2022-07-14 tracey #include <event.h>
26 a596b957 2022-07-14 tracey #include <imsg.h>
27 a596b957 2022-07-14 tracey #include <stdlib.h>
28 a596b957 2022-07-14 tracey #include <stdio.h>
29 a596b957 2022-07-14 tracey #include <string.h>
30 a596b957 2022-07-14 tracey #include <time.h>
31 a596b957 2022-07-14 tracey #include <unistd.h>
33 a596b957 2022-07-14 tracey #include "got_error.h"
35 a596b957 2022-07-14 tracey #include "proc.h"
36 a596b957 2022-07-14 tracey #include "gotwebd.h"
38 a596b957 2022-07-14 tracey size_t fcgi_parse_record(uint8_t *, size_t, struct request *);
39 a596b957 2022-07-14 tracey void fcgi_parse_begin_request(uint8_t *, uint16_t, struct request *,
40 a596b957 2022-07-14 tracey uint16_t);
41 a596b957 2022-07-14 tracey void fcgi_parse_params(uint8_t *, uint16_t, struct request *, uint16_t);
42 a596b957 2022-07-14 tracey void fcgi_send_response(struct request *, struct fcgi_response *);
44 a596b957 2022-07-14 tracey void dump_fcgi_record_header(const char *, struct fcgi_record_header *);
45 a596b957 2022-07-14 tracey void dump_fcgi_begin_request_body(const char *,
46 a596b957 2022-07-14 tracey struct fcgi_begin_request_body *);
47 a596b957 2022-07-14 tracey void dump_fcgi_end_request_body(const char *,
48 a596b957 2022-07-14 tracey struct fcgi_end_request_body *);
50 a596b957 2022-07-14 tracey extern int cgi_inflight;
51 a596b957 2022-07-14 tracey extern volatile int client_cnt;
54 a596b957 2022-07-14 tracey fcgi_request(int fd, short events, void *arg)
56 a596b957 2022-07-14 tracey struct request *c = arg;
57 a596b957 2022-07-14 tracey ssize_t n;
58 a596b957 2022-07-14 tracey size_t parsed = 0;
60 a596b957 2022-07-14 tracey n = read(fd, c->buf + c->buf_pos + c->buf_len,
61 a596b957 2022-07-14 tracey FCGI_RECORD_SIZE - c->buf_pos-c->buf_len);
63 a596b957 2022-07-14 tracey switch (n) {
65 a596b957 2022-07-14 tracey switch (errno) {
66 a596b957 2022-07-14 tracey case EINTR:
67 a596b957 2022-07-14 tracey case EAGAIN:
70 a596b957 2022-07-14 tracey goto fail;
75 a596b957 2022-07-14 tracey log_debug("closed connection");
76 a596b957 2022-07-14 tracey goto fail;
81 a596b957 2022-07-14 tracey c->buf_len += n;
84 a596b957 2022-07-14 tracey * Parse the records as they are received. Per the FastCGI
85 a596b957 2022-07-14 tracey * specification, the server need only receive the FastCGI
86 a596b957 2022-07-14 tracey * parameter records in full; it is free to begin execution
87 a596b957 2022-07-14 tracey * at that point, which is what happens here.
90 a596b957 2022-07-14 tracey parsed = fcgi_parse_record(c->buf + c->buf_pos, c->buf_len, c);
91 a596b957 2022-07-14 tracey if (parsed != 0) {
92 a596b957 2022-07-14 tracey c->buf_pos += parsed;
93 a596b957 2022-07-14 tracey c->buf_len -= parsed;
95 a596b957 2022-07-14 tracey } while (parsed > 0 && c->buf_len > 0);
97 a596b957 2022-07-14 tracey /* Make space for further reads */
98 a596b957 2022-07-14 tracey if (parsed != 0)
99 a596b957 2022-07-14 tracey if (c->buf_len > 0) {
100 a596b957 2022-07-14 tracey bcopy(c->buf + c->buf_pos, c->buf, c->buf_len);
101 a596b957 2022-07-14 tracey c->buf_pos = 0;
105 a596b957 2022-07-14 tracey fcgi_cleanup_request(c);
109 a596b957 2022-07-14 tracey fcgi_parse_record(uint8_t *buf, size_t n, struct request *c)
111 a596b957 2022-07-14 tracey struct fcgi_record_header *h;
113 a596b957 2022-07-14 tracey if (n < sizeof(struct fcgi_record_header))
114 a596b957 2022-07-14 tracey return 0;
116 a596b957 2022-07-14 tracey h = (struct fcgi_record_header*) buf;
118 a596b957 2022-07-14 tracey dump_fcgi_record("", h);
120 a596b957 2022-07-14 tracey if (n < sizeof(struct fcgi_record_header) + ntohs(h->content_len)
121 a596b957 2022-07-14 tracey + h->padding_len)
122 a596b957 2022-07-14 tracey return 0;
124 a596b957 2022-07-14 tracey if (h->version != 1)
125 a596b957 2022-07-14 tracey log_warn("wrong version");
127 a596b957 2022-07-14 tracey switch (h->type) {
128 a596b957 2022-07-14 tracey case FCGI_BEGIN_REQUEST:
129 a596b957 2022-07-14 tracey fcgi_parse_begin_request(buf +
130 a596b957 2022-07-14 tracey sizeof(struct fcgi_record_header),
131 a596b957 2022-07-14 tracey ntohs(h->content_len), c, ntohs(h->id));
133 a596b957 2022-07-14 tracey case FCGI_PARAMS:
134 a596b957 2022-07-14 tracey fcgi_parse_params(buf + sizeof(struct fcgi_record_header),
135 a596b957 2022-07-14 tracey ntohs(h->content_len), c, ntohs(h->id));
137 a596b957 2022-07-14 tracey case FCGI_STDIN:
138 a596b957 2022-07-14 tracey case FCGI_ABORT_REQUEST:
139 a596b957 2022-07-14 tracey fcgi_create_end_record(c);
140 a596b957 2022-07-14 tracey fcgi_cleanup_request(c);
141 a596b957 2022-07-14 tracey return 0;
143 a596b957 2022-07-14 tracey log_warn("unimplemented type %d", h->type);
147 a596b957 2022-07-14 tracey return (sizeof(struct fcgi_record_header) + ntohs(h->content_len)
148 a596b957 2022-07-14 tracey + h->padding_len);
152 a596b957 2022-07-14 tracey fcgi_parse_begin_request(uint8_t *buf, uint16_t n,
153 a596b957 2022-07-14 tracey struct request *c, uint16_t id)
155 a596b957 2022-07-14 tracey /* XXX -- FCGI_CANT_MPX_CONN */
156 a596b957 2022-07-14 tracey if (c->request_started) {
157 a596b957 2022-07-14 tracey log_warn("unexpected FCGI_BEGIN_REQUEST, ignoring");
161 a596b957 2022-07-14 tracey if (n != sizeof(struct fcgi_begin_request_body)) {
162 a596b957 2022-07-14 tracey log_warn("wrong size %d != %lu", n,
163 a596b957 2022-07-14 tracey sizeof(struct fcgi_begin_request_body));
167 a596b957 2022-07-14 tracey c->request_started = 1;
169 a596b957 2022-07-14 tracey c->id = id;
170 a596b957 2022-07-14 tracey SLIST_INIT(&c->env);
171 a596b957 2022-07-14 tracey c->env_count = 0;
175 a596b957 2022-07-14 tracey fcgi_parse_params(uint8_t *buf, uint16_t n, struct request *c, uint16_t id)
177 a596b957 2022-07-14 tracey struct env_val *env_entry;
178 a596b957 2022-07-14 tracey uint32_t name_len, val_len;
179 a596b957 2022-07-14 tracey uint8_t *sd, *dr_buf;
181 a596b957 2022-07-14 tracey if (!c->request_started) {
182 a596b957 2022-07-14 tracey log_warn("FCGI_PARAMS without FCGI_BEGIN_REQUEST, ignoring");
186 a596b957 2022-07-14 tracey if (c->id != id) {
187 a596b957 2022-07-14 tracey log_warn("unexpected id, ignoring");
191 a596b957 2022-07-14 tracey if (n == 0) {
192 a596b957 2022-07-14 tracey gotweb_process_request(c);
196 a596b957 2022-07-14 tracey while (n > 0) {
197 a596b957 2022-07-14 tracey if (buf[0] >> 7 == 0) {
198 a596b957 2022-07-14 tracey name_len = buf[0];
202 a596b957 2022-07-14 tracey if (n > 3) {
203 a596b957 2022-07-14 tracey name_len = ((buf[0] & 0x7f) << 24) +
204 a596b957 2022-07-14 tracey (buf[1] << 16) + (buf[2] << 8) + buf[3];
206 a596b957 2022-07-14 tracey buf += 4;
211 a596b957 2022-07-14 tracey if (n > 0) {
212 a596b957 2022-07-14 tracey if (buf[0] >> 7 == 0) {
213 a596b957 2022-07-14 tracey val_len = buf[0];
217 a596b957 2022-07-14 tracey if (n > 3) {
218 a596b957 2022-07-14 tracey val_len = ((buf[0] & 0x7f) << 24) +
219 a596b957 2022-07-14 tracey (buf[1] << 16) + (buf[2] << 8) +
222 a596b957 2022-07-14 tracey buf += 4;
229 a596b957 2022-07-14 tracey if (n < name_len + val_len)
232 a596b957 2022-07-14 tracey if ((env_entry = malloc(sizeof(struct env_val))) == NULL) {
233 a596b957 2022-07-14 tracey log_warn("cannot malloc env_entry");
237 a596b957 2022-07-14 tracey if ((env_entry->val = calloc(sizeof(char), name_len + val_len +
238 a596b957 2022-07-14 tracey 2)) == NULL) {
239 a596b957 2022-07-14 tracey log_warn("cannot allocate env_entry->val");
240 a596b957 2022-07-14 tracey free(env_entry);
244 a596b957 2022-07-14 tracey bcopy(buf, env_entry->val, name_len);
245 a596b957 2022-07-14 tracey buf += name_len;
246 a596b957 2022-07-14 tracey n -= name_len;
248 a596b957 2022-07-14 tracey env_entry->val[name_len] = '\0';
249 a596b957 2022-07-14 tracey if (val_len < MAX_QUERYSTRING && strcmp(env_entry->val,
250 a596b957 2022-07-14 tracey "QUERY_STRING") == 0 && c->querystring[0] == '\0') {
251 a596b957 2022-07-14 tracey bcopy(buf, c->querystring, val_len);
252 a596b957 2022-07-14 tracey c->querystring[val_len] = '\0';
254 a596b957 2022-07-14 tracey if (val_len < GOTWEBD_MAXTEXT && strcmp(env_entry->val,
255 a596b957 2022-07-14 tracey "HTTP_HOST") == 0 && c->http_host[0] == '\0') {
258 a596b957 2022-07-14 tracey * lazily get subdomain
259 a596b957 2022-07-14 tracey * will only get domain if no subdomain exists
260 a596b957 2022-07-14 tracey * this can still work if gotweb server name is the same
262 a596b957 2022-07-14 tracey sd = strchr(buf, '.');
264 a596b957 2022-07-14 tracey *sd = '\0';
266 a596b957 2022-07-14 tracey bcopy(buf, c->http_host, val_len);
267 a596b957 2022-07-14 tracey c->http_host[val_len] = '\0';
269 a596b957 2022-07-14 tracey if (val_len < MAX_DOCUMENT_ROOT && strcmp(env_entry->val,
270 a596b957 2022-07-14 tracey "DOCUMENT_ROOT") == 0 && c->document_root[0] == '\0') {
272 a596b957 2022-07-14 tracey /* drop first char, as it's always / */
273 a596b957 2022-07-14 tracey dr_buf = &buf[1];
275 a596b957 2022-07-14 tracey bcopy(dr_buf, c->document_root, val_len - 1);
276 a596b957 2022-07-14 tracey c->document_root[val_len] = '\0';
278 a596b957 2022-07-14 tracey if (val_len < MAX_SERVER_NAME && strcmp(env_entry->val,
279 a596b957 2022-07-14 tracey "SERVER_NAME") == 0 && c->server_name[0] == '\0') {
280 a596b957 2022-07-14 tracey /* drop first char, as it's always / */
282 a596b957 2022-07-14 tracey bcopy(buf, c->server_name, val_len);
283 a596b957 2022-07-14 tracey c->server_name[val_len] = '\0';
285 a596b957 2022-07-14 tracey env_entry->val[name_len] = '=';
287 a596b957 2022-07-14 tracey bcopy(buf, (env_entry->val) + name_len + 1, val_len);
288 a596b957 2022-07-14 tracey buf += val_len;
289 a596b957 2022-07-14 tracey n -= val_len;
291 a596b957 2022-07-14 tracey SLIST_INSERT_HEAD(&c->env, env_entry, entry);
292 a596b957 2022-07-14 tracey log_debug("env[%d], %s", c->env_count, env_entry->val);
293 a596b957 2022-07-14 tracey c->env_count++;
298 a596b957 2022-07-14 tracey fcgi_timeout(int fd, short events, void *arg)
300 a596b957 2022-07-14 tracey fcgi_cleanup_request((struct request*) arg);
304 a596b957 2022-07-14 tracey fcgi_gen_binary_response(struct request *c, const uint8_t *data, int len)
306 a596b957 2022-07-14 tracey struct fcgi_response *resp;
307 a596b957 2022-07-14 tracey struct fcgi_record_header *header;
308 a596b957 2022-07-14 tracey ssize_t n = 0;
311 a596b957 2022-07-14 tracey if (c->sock->client_status == CLIENT_DISCONNECT)
312 a596b957 2022-07-14 tracey return -1;
314 9dd0e5e9 2022-07-28 op if (data == NULL || len == 0)
315 a596b957 2022-07-14 tracey return 0;
317 a596b957 2022-07-14 tracey if ((resp = calloc(1, sizeof(struct fcgi_response))) == NULL) {
318 a596b957 2022-07-14 tracey log_warn("%s: cannot calloc fcgi_response", __func__);
319 a596b957 2022-07-14 tracey return -1;
322 a596b957 2022-07-14 tracey header = (struct fcgi_record_header*) resp->data;
323 a596b957 2022-07-14 tracey header->version = 1;
324 a596b957 2022-07-14 tracey header->type = FCGI_STDOUT;
325 a596b957 2022-07-14 tracey header->id = htons(c->id);
326 a596b957 2022-07-14 tracey header->padding_len = 0;
327 a596b957 2022-07-14 tracey header->reserved = 0;
329 a596b957 2022-07-14 tracey for (i = 0; i < len; i++) {
330 a596b957 2022-07-14 tracey resp->data[i+8] = data[i];
334 a596b957 2022-07-14 tracey header->content_len = htons(n);
335 a596b957 2022-07-14 tracey resp->data_pos = 0;
336 a596b957 2022-07-14 tracey resp->data_len = n + sizeof(struct fcgi_record_header);
337 a596b957 2022-07-14 tracey fcgi_send_response(c, resp);
339 a596b957 2022-07-14 tracey return 0;
343 a596b957 2022-07-14 tracey fcgi_gen_response(struct request *c, const char *data)
345 9dd0e5e9 2022-07-28 op if (data == NULL || *data == '\0')
346 a596b957 2022-07-14 tracey return 0;
347 9dd0e5e9 2022-07-28 op return fcgi_gen_binary_response(c, data, strlen(data));
351 a596b957 2022-07-14 tracey fcgi_send_response(struct request *c, struct fcgi_response *resp)
353 a596b957 2022-07-14 tracey struct fcgi_record_header *header;
354 a596b957 2022-07-14 tracey struct timespec ts;
355 cb8b8986 2022-07-28 op size_t padded_len, off;
357 a596b957 2022-07-14 tracey int err = 0, th = 2000;
359 a596b957 2022-07-14 tracey ts.tv_sec = 0;
360 a596b957 2022-07-14 tracey ts.tv_nsec = 50;
362 a596b957 2022-07-14 tracey header = (struct fcgi_record_header*)resp->data;
364 a596b957 2022-07-14 tracey /* The FastCGI spec suggests to align the output buffer */
365 a596b957 2022-07-14 tracey padded_len = FCGI_ALIGN(resp->data_len);
366 a596b957 2022-07-14 tracey if (padded_len > resp->data_len) {
367 a596b957 2022-07-14 tracey /* There should always be FCGI_PADDING_SIZE bytes left */
368 a596b957 2022-07-14 tracey if (padded_len > FCGI_RECORD_SIZE)
369 a596b957 2022-07-14 tracey log_warn("response too long");
370 a596b957 2022-07-14 tracey header->padding_len = padded_len - resp->data_len;
371 a596b957 2022-07-14 tracey resp->data_len = padded_len;
374 a596b957 2022-07-14 tracey dump_fcgi_record("resp ", header);
377 a596b957 2022-07-14 tracey * XXX: add some simple write heuristics here
378 a596b957 2022-07-14 tracey * On slower VMs, spotty connections, etc., we don't want to go right to
379 a596b957 2022-07-14 tracey * disconnect. Let's at least try to write the data a few times before
380 a596b957 2022-07-14 tracey * giving up.
382 cb8b8986 2022-07-28 op for (off = 0; off < resp->data_len; off += nw) {
383 cb8b8986 2022-07-28 op nw = write(c->fd, resp->data + off, resp->data_len - off);
384 cb8b8986 2022-07-28 op if (nw == 0) {
385 cb8b8986 2022-07-28 op c->sock->client_status = CLIENT_DISCONNECT;
388 cb8b8986 2022-07-28 op if (nw == -1) {
390 cb8b8986 2022-07-28 op if (errno == EAGAIN && err < th) {
392 cb8b8986 2022-07-28 op nanosleep(&ts, NULL);
395 b43fa49a 2022-07-28 op log_warn("%s: write failure", __func__);
396 a596b957 2022-07-14 tracey c->sock->client_status = CLIENT_DISCONNECT;
400 cb8b8986 2022-07-28 op if (nw != resp->data_len - off)
401 cb8b8986 2022-07-28 op log_debug("partial write: %zu vs %zu", nw,
402 cb8b8986 2022-07-28 op resp->data_len - off);
405 a596b957 2022-07-14 tracey free(resp);
409 a596b957 2022-07-14 tracey fcgi_create_end_record(struct request *c)
411 a596b957 2022-07-14 tracey struct fcgi_response *resp;
412 a596b957 2022-07-14 tracey struct fcgi_record_header *header;
413 a596b957 2022-07-14 tracey struct fcgi_end_request_body *end_request;
415 a596b957 2022-07-14 tracey if ((resp = calloc(1, sizeof(struct fcgi_response))) == NULL) {
416 a596b957 2022-07-14 tracey log_warn("cannot calloc fcgi_response");
419 a596b957 2022-07-14 tracey header = (struct fcgi_record_header*) resp->data;
420 a596b957 2022-07-14 tracey header->version = 1;
421 a596b957 2022-07-14 tracey header->type = FCGI_END_REQUEST;
422 a596b957 2022-07-14 tracey header->id = htons(c->id);
423 a596b957 2022-07-14 tracey header->content_len = htons(sizeof(struct
424 a596b957 2022-07-14 tracey fcgi_end_request_body));
425 a596b957 2022-07-14 tracey header->padding_len = 0;
426 a596b957 2022-07-14 tracey header->reserved = 0;
427 a596b957 2022-07-14 tracey end_request = (struct fcgi_end_request_body *) (resp->data +
428 a596b957 2022-07-14 tracey sizeof(struct fcgi_record_header));
429 a596b957 2022-07-14 tracey end_request->app_status = htonl(0); /* script_status */
430 a596b957 2022-07-14 tracey end_request->protocol_status = FCGI_REQUEST_COMPLETE;
431 a596b957 2022-07-14 tracey end_request->reserved[0] = 0;
432 a596b957 2022-07-14 tracey end_request->reserved[1] = 0;
433 a596b957 2022-07-14 tracey end_request->reserved[2] = 0;
434 a596b957 2022-07-14 tracey resp->data_pos = 0;
435 a596b957 2022-07-14 tracey resp->data_len = sizeof(struct fcgi_end_request_body) +
436 a596b957 2022-07-14 tracey sizeof(struct fcgi_record_header);
437 a596b957 2022-07-14 tracey fcgi_send_response(c, resp);
441 a596b957 2022-07-14 tracey fcgi_cleanup_request(struct request *c)
443 a596b957 2022-07-14 tracey cgi_inflight--;
444 a596b957 2022-07-14 tracey client_cnt--;
446 a596b957 2022-07-14 tracey evtimer_del(&c->tmo);
447 a596b957 2022-07-14 tracey if (event_initialized(&c->ev))
448 a596b957 2022-07-14 tracey event_del(&c->ev);
450 a596b957 2022-07-14 tracey close(c->fd);
451 a596b957 2022-07-14 tracey gotweb_free_transport(c->t);
456 a596b957 2022-07-14 tracey dump_fcgi_record(const char *p, struct fcgi_record_header *h)
458 a596b957 2022-07-14 tracey dump_fcgi_record_header(p, h);
460 a596b957 2022-07-14 tracey if (h->type == FCGI_BEGIN_REQUEST)
461 a596b957 2022-07-14 tracey dump_fcgi_begin_request_body(p,
462 a596b957 2022-07-14 tracey (struct fcgi_begin_request_body *)(h + 1));
463 a596b957 2022-07-14 tracey else if (h->type == FCGI_END_REQUEST)
464 a596b957 2022-07-14 tracey dump_fcgi_end_request_body(p,
465 a596b957 2022-07-14 tracey (struct fcgi_end_request_body *)(h + 1));
469 a596b957 2022-07-14 tracey dump_fcgi_record_header(const char* p, struct fcgi_record_header *h)
471 a596b957 2022-07-14 tracey log_debug("%sversion: %d", p, h->version);
472 a596b957 2022-07-14 tracey log_debug("%stype: %d", p, h->type);
473 a596b957 2022-07-14 tracey log_debug("%srequestId: %d", p, ntohs(h->id));
474 a596b957 2022-07-14 tracey log_debug("%scontentLength: %d", p, ntohs(h->content_len));
475 a596b957 2022-07-14 tracey log_debug("%spaddingLength: %d", p, h->padding_len);
476 a596b957 2022-07-14 tracey log_debug("%sreserved: %d", p, h->reserved);
480 a596b957 2022-07-14 tracey dump_fcgi_begin_request_body(const char *p, struct fcgi_begin_request_body *b)
482 a596b957 2022-07-14 tracey log_debug("%srole %d", p, ntohs(b->role));
483 a596b957 2022-07-14 tracey log_debug("%sflags %d", p, b->flags);
487 a596b957 2022-07-14 tracey dump_fcgi_end_request_body(const char *p, struct fcgi_end_request_body *b)
489 a596b957 2022-07-14 tracey log_debug("%sappStatus: %d", p, ntohl(b->app_status));
490 a596b957 2022-07-14 tracey log_debug("%sprotocolStatus: %d", p, b->protocol_status);