* Optional - iteration continues automatically if this is NULL. */
protolayer_event_cb event_wrap;
- /** Modifies the provided request for use with the layer. */
+ /** Modifies the provided request for use with the layer. Mostly for
+ * setting `struct kr_request::qsource.comm_flags`. */
protolayer_request_cb request_init;
};
void session2_event_after(struct session2 *s, enum protolayer_protocol protocol,
enum protolayer_event_type event, void *baton);
+/** Performs initial setup of the specified `req`, using the session's protocol
+ * layers. Layers are processed in the `_UNWRAP` direction. */
void session2_init_request(struct session2 *s, struct kr_request *req);
/** Removes the specified request task from the session's tasklist. The session
return true;
}
+static void pl_tls_request_init(struct protolayer_manager *manager,
+ struct kr_request *req,
+ void *sess_data)
+{
+ req->qsource.comm_flags.tls = true;
+}
+
void tls_protolayers_init(void)
{
protolayer_globals[PROTOLAYER_TLS] = (struct protolayer_globals){
.wrap = pl_tls_wrap,
.event_unwrap = pl_tls_event_unwrap,
.event_wrap = pl_tls_event_wrap,
+ .request_init = pl_tls_request_init
};
}
const struct sockaddr *dst_addr = comm->dst_addr;
const struct proxy_result *proxy = comm->proxy;
- req->qsource.comm_flags.tcp = session->stream;
- req->qsource.comm_flags.tls = session->secure;
+ req->qsource.stream_id = -1;
+ session2_init_request(session, req);
req->qsource.flags = req->qsource.comm_flags;
if (proxy) {
req->qsource.flags.tls = proxy->has_tls;
}
- req->qsource.stream_id = -1;
-
- session2_init_request(session, req);
-
/* We need to store a copy of peer address. */
memcpy(&ctx->source.addr.ip, src_addr, kr_sockaddr_len(src_addr));
req->qsource.addr = &ctx->source.addr.ip;
}
}
+static void pl_dns_stream_request_init(struct protolayer_manager *manager,
+ struct kr_request *req,
+ void *sess_data)
+{
+ req->qsource.comm_flags.tcp = true;
+}
int worker_init(void)
{
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
+ .event_unwrap = pl_dns_stream_event_unwrap,
+ .request_init = pl_dns_stream_request_init
};
const struct protolayer_globals stream_common = {
.sess_size = sizeof(struct pl_dns_stream_sess_data),
.iter_deinit = pl_dns_stream_iter_deinit,
.unwrap = pl_dns_stream_unwrap,
.wrap = pl_dns_stream_wrap,
- .event_unwrap = pl_dns_stream_event_unwrap
+ .event_unwrap = pl_dns_stream_event_unwrap,
+ .request_init = pl_dns_stream_request_init
};
protolayer_globals[PROTOLAYER_DNS_MULTI_STREAM] = stream_common;
protolayer_globals[PROTOLAYER_DNS_MULTI_STREAM].sess_init = pl_dns_stream_sess_init;