cf-capsule: complete filter

Make the capsule filter complete, implement:

- pollset handling
- flush handling and querying
- shutdown handling
- replace allocated send buffer with a bufq

Closes #22019
This commit is contained in:
Stefan Eissing 2026-06-15 12:34:09 +02:00 committed by Daniel Stenberg
parent c8d8f081fd
commit 7333f6674c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 158 additions and 113 deletions

View file

@ -98,7 +98,6 @@ static void check_capsule_result(struct bufq *q,
static void test_capsule_encode_decode_roundtrip(void)
{
struct dynbuf dyn;
struct bufq q;
unsigned char payload[128];
unsigned char out[128];
@ -106,20 +105,19 @@ static void test_capsule_encode_decode_roundtrip(void)
size_t payload_len;
size_t i, nread;
Curl_bufq_init2(&q, 32, 8, BUFQ_OPT_NONE);
for(i = 0; i < sizeof(payload); ++i)
payload[i] = (unsigned char)i;
for(i = 0; i < 2; ++i) {
payload_len = i ? 64 : 7;
memset(out, 0, sizeof(out));
Curl_bufq_reset(&q);
result = Curl_capsule_encap_udp_datagram(&dyn, payload, payload_len);
result = Curl_capsule_encap_udp_datagram(&q, payload, payload_len);
fail_unless(result == CURLE_OK, "failed to encapsulate UDP datagram");
Curl_bufq_init2(&q, 32, 8, BUFQ_OPT_NONE);
queue_bytes(&q, (const unsigned char *)curlx_dyn_ptr(&dyn),
curlx_dyn_len(&dyn));
err = CURLE_OK;
nread = Curl_capsule_process_udp_raw(NULL, NULL, &q, out, sizeof(out),
&err);
@ -128,10 +126,8 @@ static void test_capsule_encode_decode_roundtrip(void)
fail_unless(!memcmp(out, payload, payload_len),
"decoded payload bytes mismatch");
fail_unless(Curl_bufq_is_empty(&q), "decoded capsule must be consumed");
Curl_bufq_free(&q);
curlx_dyn_free(&dyn);
}
Curl_bufq_free(&q);
}
static void test_capsule_sequential_decode(void)