diff --git a/daemon/session2.c b/daemon/session2.c index 7a5ce454d..52042f49b 100644 --- a/daemon/session2.c +++ b/daemon/session2.c @@ -37,14 +37,14 @@ static enum protolayer_protocol protolayer_grp_doudp[] = { static enum protolayer_protocol protolayer_grp_dotcp[] = { PROTOLAYER_TCP, - PROTOLAYER_DNS_MSTREAM, + PROTOLAYER_DNS_MULTI_STREAM, PROTOLAYER_NULL }; static enum protolayer_protocol protolayer_grp_dot[] = { PROTOLAYER_TCP, PROTOLAYER_TLS, - PROTOLAYER_DNS_MSTREAM, + PROTOLAYER_DNS_MULTI_STREAM, PROTOLAYER_NULL }; @@ -52,7 +52,7 @@ static enum protolayer_protocol protolayer_grp_doh[] = { PROTOLAYER_TCP, PROTOLAYER_TLS, PROTOLAYER_HTTP, - PROTOLAYER_DNS_DGRAM, + PROTOLAYER_DNS_UNSIZED_STREAM, PROTOLAYER_NULL }; diff --git a/daemon/session2.h b/daemon/session2.h index c230d2929..880b4206a 100644 --- a/daemon/session2.h +++ b/daemon/session2.h @@ -82,19 +82,21 @@ struct comm_info { * processed. See `PROTOLAYER_GRP_MAP` below for more details. */ #define PROTOLAYER_PROTOCOL_MAP(XX) \ /* General transport protocols */\ - XX(UDP) \ - XX(TCP) \ - XX(TLS) \ - XX(HTTP) \ - \ - /* QUIC (not yet implemented) */\ - XX(UDP_TO_QCONN)\ - XX(QCONN_TO_QSTREAM)\ + XX(UDP)\ + XX(TCP)\ + XX(TLS)\ + XX(HTTP)\ \ /* DNS (`worker`) */\ - XX(DNS_DGRAM)\ - XX(DNS_MSTREAM)\ - XX(DNS_SSTREAM) + XX(DNS_DGRAM) /**< Packets WITHOUT prepended size, one per (un)wrap, + * limited to UDP sizes, multiple sources (single + * session for multiple clients). */\ + XX(DNS_UNSIZED_STREAM) /**< Singular packet WITHOUT prepended size, one + * per (un)wrap, no UDP limits, single source. */\ + XX(DNS_MULTI_STREAM) /**< Multiple packets WITH prepended sizes in a + * stream (may span multiple (un)wraps). */\ + XX(DNS_SINGLE_STREAM) /**< Singular packet WITH prepended size in a + * stream (may span multiple (un)wraps). */ /** The identifiers of protocol layer types. */ enum protolayer_protocol { diff --git a/daemon/worker.c b/daemon/worker.c index 5a1b4be84..f15576480 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1938,40 +1938,21 @@ struct pl_dns_stream_iter_data { } sent; }; -static void pl_dns_stream_sess_init_common(struct session2 *session, - struct pl_dns_stream_sess_data *stream, - bool single) +static int pl_dns_stream_sess_init(struct protolayer_manager *manager, + void *sess_data, void *param) { - session->stream = true; - *stream = (struct pl_dns_stream_sess_data){ - .single = single - }; -} - -static int pl_dns_mstream_sess_init(struct protolayer_manager *manager, - void *sess_data, - void *param) -{ - struct pl_dns_stream_sess_data *stream = sess_data; - pl_dns_stream_sess_init_common(manager->session, stream, false); + /* _UNSIZED_STREAM and _MULTI_STREAM - don't forget to split if needed + * at some point */ + manager->session->stream = true; return kr_ok(); } -static int pl_dns_sstream_sess_init(struct protolayer_manager *manager, - void *sess_data, - void *param) +static int pl_dns_single_stream_sess_init(struct protolayer_manager *manager, + void *sess_data, void *param) { + manager->session->stream = true; struct pl_dns_stream_sess_data *stream = sess_data; - pl_dns_stream_sess_init_common(manager->session, stream, true); - return kr_ok(); -} - -static int pl_dns_stream_iter_init(struct protolayer_manager *manager, - struct protolayer_iter_ctx *ctx, - void *iter_data) -{ - struct pl_dns_stream_iter_data *stream = iter_data; - *stream = (struct pl_dns_stream_iter_data){0}; + stream->single = true; return kr_ok(); } @@ -2320,20 +2301,24 @@ int worker_init(void) .unwrap = pl_dns_dgram_unwrap, .event_unwrap = pl_dns_dgram_event_unwrap }; + protolayer_globals[PROTOLAYER_DNS_UNSIZED_STREAM] = (struct protolayer_globals){ + .sess_init = pl_dns_stream_sess_init, + .unwrap = pl_dns_dgram_unwrap, + .event_unwrap = pl_dns_stream_event_unwrap + }; const struct protolayer_globals stream_common = { .sess_size = sizeof(struct pl_dns_stream_sess_data), .sess_init = NULL, /* replaced in specific layers below */ .iter_size = sizeof(struct pl_dns_stream_iter_data), - .iter_init = pl_dns_stream_iter_init, .iter_deinit = pl_dns_stream_iter_deinit, .unwrap = pl_dns_stream_unwrap, .wrap = pl_dns_stream_wrap, .event_unwrap = pl_dns_stream_event_unwrap }; - protolayer_globals[PROTOLAYER_DNS_MSTREAM] = stream_common; - protolayer_globals[PROTOLAYER_DNS_MSTREAM].sess_init = pl_dns_mstream_sess_init; - protolayer_globals[PROTOLAYER_DNS_SSTREAM] = stream_common; - protolayer_globals[PROTOLAYER_DNS_SSTREAM].sess_init = pl_dns_sstream_sess_init; + protolayer_globals[PROTOLAYER_DNS_MULTI_STREAM] = stream_common; + protolayer_globals[PROTOLAYER_DNS_MULTI_STREAM].sess_init = pl_dns_stream_sess_init; + protolayer_globals[PROTOLAYER_DNS_SINGLE_STREAM] = stream_common; + protolayer_globals[PROTOLAYER_DNS_SINGLE_STREAM].sess_init = pl_dns_single_stream_sess_init; /* Create main worker. */ the_worker = &the_worker_value;