mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-10 10:00:53 -04:00
MINOR: quic: use signed char type for ALPN manipulation
In most of haproxy code, ALPN is used as a signed char pointer. In QUIC code instead, it is manipulated as unsigned. Unifies this by using signed type in QUIC code. This allows to remove a bunch of unnecessary casts.
This commit is contained in:
parent
13c3445163
commit
58830990d0
4 changed files with 11 additions and 11 deletions
|
|
@ -84,7 +84,7 @@ void qc_check_close_on_released_mux(struct quic_conn *qc);
|
|||
int quic_stateless_reset_token_cpy(unsigned char *pos, size_t len,
|
||||
const unsigned char *salt, size_t saltlen);
|
||||
int quic_reuse_srv_params(struct quic_conn *qc,
|
||||
const unsigned char *alpn,
|
||||
const char *alpn,
|
||||
const struct quic_early_transport_params *etps);
|
||||
|
||||
/* Returns true if <qc> is used on the backed side (as a client). */
|
||||
|
|
@ -204,7 +204,7 @@ static inline void *qc_counters(enum obj_type *o, const struct stats_module *m)
|
|||
void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm);
|
||||
void quic_set_connection_close(struct quic_conn *qc, const struct quic_err err);
|
||||
void quic_set_tls_alert(struct quic_conn *qc, int alert);
|
||||
int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alpn_len);
|
||||
int quic_set_app_ops(struct quic_conn *qc, const char *alpn, int alpn_len);
|
||||
int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len);
|
||||
|
||||
void qc_notify_err(struct quic_conn *qc);
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ void quic_set_tls_alert(struct quic_conn *qc, int alert)
|
|||
/* Set the application for <qc> QUIC connection.
|
||||
* Return 1 if succeeded, 0 if not.
|
||||
*/
|
||||
int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alpn_len)
|
||||
int quic_set_app_ops(struct quic_conn *qc, const char *alpn, int alpn_len)
|
||||
{
|
||||
if (alpn_len >= 2 && memcmp(alpn, "h3", 2) == 0)
|
||||
qc->app_ops = &h3_ops;
|
||||
|
|
@ -290,14 +290,14 @@ int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alp
|
|||
* Return 1 if succeeded, 0 if not.
|
||||
*/
|
||||
int quic_reuse_srv_params(struct quic_conn *qc,
|
||||
const unsigned char *alpn,
|
||||
const char *alpn,
|
||||
const struct quic_early_transport_params *etps)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
TRACE_ENTER(QUIC_EV_CONN_NEW, qc);
|
||||
|
||||
if (!alpn || !quic_set_app_ops(qc, alpn, strlen((char *)alpn)))
|
||||
if (!alpn || !quic_set_app_ops(qc, alpn, strlen(alpn)))
|
||||
goto err;
|
||||
|
||||
qc_early_transport_params_reuse(qc, &qc->tx.params, etps);
|
||||
|
|
|
|||
|
|
@ -1011,11 +1011,11 @@ int qc_ssl_do_hanshake(struct quic_conn *qc, struct ssl_sock_ctx *ctx)
|
|||
}
|
||||
}
|
||||
else if (qc->conn) {
|
||||
const unsigned char *alpn;
|
||||
size_t alpn_len;
|
||||
const char *alpn;
|
||||
int alpn_len;
|
||||
|
||||
qc->conn->flags &= ~(CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN);
|
||||
if (!ssl_sock_get_alpn(qc->conn, ctx, (const char **)&alpn, (int *)&alpn_len) ||
|
||||
if (!ssl_sock_get_alpn(qc->conn, ctx, &alpn, &alpn_len) ||
|
||||
!quic_set_app_ops(qc, alpn, alpn_len)) {
|
||||
TRACE_ERROR("No negotiated ALPN", QUIC_EV_CONN_IO_CB, qc, &state);
|
||||
quic_set_tls_alert(qc, SSL_AD_NO_APPLICATION_PROTOCOL);
|
||||
|
|
@ -1358,7 +1358,7 @@ int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target)
|
|||
#if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L) && defined(HAVE_SSL_0RTT_QUIC)
|
||||
if ((srv->ssl_ctx.options & SRV_SSL_O_EARLY_DATA)) {
|
||||
int ret;
|
||||
unsigned char *alpn;
|
||||
char *alpn;
|
||||
struct quic_early_transport_params *etps;
|
||||
/* This code is called by connect_server() by way of
|
||||
* conn_prepare().
|
||||
|
|
@ -1374,7 +1374,7 @@ int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target)
|
|||
* able to send data at early-data level.
|
||||
*/
|
||||
HA_RWLOCK_RDLOCK(SERVER_LOCK, &srv->path_params.param_lock);
|
||||
alpn = (unsigned char *)srv->path_params.nego_alpn;
|
||||
alpn = srv->path_params.nego_alpn;
|
||||
etps = &srv->path_params.tps;
|
||||
ret = quic_reuse_srv_params(qc, alpn, etps);
|
||||
HA_RWLOCK_RDUNLOCK(SERVER_LOCK, &srv->path_params.param_lock);
|
||||
|
|
|
|||
|
|
@ -2242,7 +2242,7 @@ static int ssl_sock_advertise_alpn_protos(SSL *s, const unsigned char **out,
|
|||
}
|
||||
|
||||
#ifdef USE_QUIC
|
||||
if (qc && !quic_set_app_ops(qc, *out, *outlen)) {
|
||||
if (qc && !quic_set_app_ops(qc, (const char *)*out, *outlen)) {
|
||||
quic_set_tls_alert(qc, SSL_AD_NO_APPLICATION_PROTOCOL);
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue