};
struct pl_http_sess_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
struct nghttp2_session *h2;
queue_http_stream streams; /* Streams present in the wire buffer. */
memcpy(send_ctx->data, data, length);
kr_log_debug(DOH, "[%p] send_callback: %p\n", (void *)h2, (void *)send_ctx->data);
- session2_wrap_after(http->session, PROTOLAYER_PROTOCOL_HTTP,
+ session2_wrap_after(http->h.session, PROTOLAYER_PROTOCOL_HTTP,
protolayer_buffer(send_ctx->data, length), NULL,
callback_finished_free_baton, send_ctx);
dest_iov[cur++] = (struct iovec){ (void *)padding, padlen - 1 };
kr_assert(cur == iovcnt);
- int ret = session2_wrap_after(http->session, PROTOLAYER_PROTOCOL_HTTP,
+ int ret = session2_wrap_after(http->h.session, PROTOLAYER_PROTOCOL_HTTP,
protolayer_iovec(dest_iov, cur),
NULL, callback_finished_free_baton, sdctx);
}
ret = 0;
- session2_unwrap_after(ctx->session, PROTOLAYER_PROTOCOL_HTTP,
+ session2_unwrap_after(ctx->h.session, PROTOLAYER_PROTOCOL_HTTP,
protolayer_wire_buf(wb), NULL, NULL, NULL);
cleanup:
http_cleanup_stream(ctx);
struct pl_udp_iter_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
struct proxy_result proxy;
bool has_proxy;
};
struct pl_tcp_sess_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
struct proxy_result proxy;
struct wire_buf wire_buf;
bool had_data : 1;
* queue iterators, as it does not need to iterate through the whole queue. */
bool protolayer_queue_has_payload(const protolayer_iter_ctx_queue_t *queue);
-/** Mandatory header members for any layer-specific data. */
-#define PROTOLAYER_DATA_HEADER() struct {\
- struct session2 *session; /**< Pointer to the owner session. */\
-}
-
-/** Layer-specific data - the generic struct. */
+/** Layer-specific data - the generic struct. To be added as the first member of
+ * each specific struct. */
struct protolayer_data {
- PROTOLAYER_DATA_HEADER();
+ struct session2 *session; /**< Pointer to the owner session. */\
};
/** Return value of `protolayer_iter_cb` callbacks. To be returned by *layer
struct protolayer_globals {
/** Size of the layer-specific data struct, valid per-session.
*
- * The struct MUST begin with the `PROTOLAYER_DATA_HEADER()` macro. If
+ * The struct MUST begin with a `struct protolayer_data` member. If
* no session struct is used by the layer, the value may be zero. */
size_t sess_size;
* gets created and destroyed together with a `struct
* protolayer_iter_ctx`.
*
- * The struct MUST begin with the `PROTOLAYER_DATA_HEADER()` macro. If
+ * The struct MUST begin with a `struct protolayer_data` member. If
* no iteration struct is used by the layer, the value may be zero. */
size_t iter_size;
} tls_hs_state_t;
struct pl_tls_sess_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
bool client_side;
bool first_handshake_done;
gnutls_session_t tls_session;
push_ctx->sess_data = tls;
memcpy(push_ctx->iov, iov, sizeof(struct iovec[iovcnt]));
- session2_wrap_after(tls->session, PROTOLAYER_PROTOCOL_TLS,
+ session2_wrap_after(tls->h.session, PROTOLAYER_PROTOCOL_TLS,
protolayer_iovec(push_ctx->iov, iovcnt), NULL,
kres_gnutls_push_finished, push_ctx);
}
struct pl_dns_stream_sess_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
bool single : 1; /**< True: Stream only allows a single packet */
bool produced : 1; /**< True: At least one packet has been produced */
};
struct pl_dns_stream_iter_data {
- PROTOLAYER_DATA_HEADER();
+ struct protolayer_data h;
struct {
knot_mm_t *pool;
void *mem;