]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: quic: Move NEW_CONNECTION_ID frame builder to quic_cid
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 07:59:15 +0000 (08:59 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 14:47:18 +0000 (15:47 +0100)
Move qc_build_new_connection_id_frm() from quic_conn.c to quic_cid.c.
Also move quic_connection_id_to_frm_cpy() from quic_conn.h to quic_cid.h.

include/haproxy/quic_cid.h
include/haproxy/quic_conn.h
src/quic_cid.c
src/quic_conn.c

index 9e02e5b5353d74ab2cccb6a96f8b3c980ee379e6..82c8ee82aabc75d66ced8d289468de79f2659cd1 100644 (file)
@@ -27,6 +27,8 @@ struct quic_conn *retrieve_qc_conn_from_cid(struct quic_rx_packet *pkt,
                                             struct listener *l,
                                             struct sockaddr_storage *saddr,
                                             int *new_tid);
+int qc_build_new_connection_id_frm(struct quic_conn *qc,
+                                   struct quic_connection_id *conn_id);
 
 /* Copy <src> QUIC CID to <dst>.
  * This is the responsibility of the caller to check there is enough room in
@@ -90,5 +92,20 @@ static inline void quic_cid_delete(struct quic_connection_id *conn_id)
        HA_RWLOCK_WRUNLOCK(QC_CID_LOCK, &tree->lock);
 }
 
+/* Copy <src> new connection ID information to <dst> NEW_CONNECTION_ID frame.
+ * Always succeeds.
+ */
+static inline void quic_connection_id_to_frm_cpy(struct quic_frame *dst,
+                                                 struct quic_connection_id *src)
+{
+       struct qf_new_connection_id *ncid_frm = &dst->new_connection_id;
+
+       ncid_frm->seq_num = src->seq_num.key;
+       ncid_frm->retire_prior_to = src->retire_prior_to;
+       ncid_frm->cid.len = src->cid.len;
+       ncid_frm->cid.data = src->cid.data;
+       ncid_frm->stateless_reset_token = src->stateless_reset_token;
+}
+
 #endif /* USE_QUIC */
 #endif /* _HAPROXY_QUIC_CID_H */
index ee11c5e237133bf1b2b464d7f25035aff34a54aa..2f2d446591410c37855ec7c48160ee29f1703de8 100644 (file)
@@ -66,8 +66,6 @@ struct quic_connection_id *new_quic_cid(struct eb_root *root,
                                         const struct sockaddr_storage *addr);
 void quic_conn_closed_err_count_inc(struct quic_conn *qc, struct quic_frame *frm);
 int qc_h3_request_reject(struct quic_conn *qc, uint64_t id);
-int qc_build_new_connection_id_frm(struct quic_conn *qc,
-                                   struct quic_connection_id *conn_id);
 struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
                               struct quic_cid *dcid, struct quic_cid *scid,
                               const struct quic_cid *token_odcid,
@@ -132,23 +130,7 @@ static inline void quic_conn_mv_cids_to_cc_conn(struct quic_conn_closed *cc_conn
 
 }
 
-/* Copy <src> new connection ID information to <dst> NEW_CONNECTION_ID frame.
- * Always succeeds.
- */
-static inline void quic_connection_id_to_frm_cpy(struct quic_frame *dst,
-                                                 struct quic_connection_id *src)
-{
-       struct qf_new_connection_id *ncid_frm = &dst->new_connection_id;
-
-       ncid_frm->seq_num = src->seq_num.key;
-       ncid_frm->retire_prior_to = src->retire_prior_to;
-       ncid_frm->cid.len = src->cid.len;
-       ncid_frm->cid.data = src->cid.data;
-       ncid_frm->stateless_reset_token = src->stateless_reset_token;
-}
-
 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);
index bef90f6938202d8dd9fad590ade838d9f07e68a0..4f1548b790de0fc701d49d9491c46024022c2eb1 100644 (file)
@@ -258,4 +258,30 @@ struct quic_conn *retrieve_qc_conn_from_cid(struct quic_rx_packet *pkt,
        return qc;
 }
 
+/* Build a NEW_CONNECTION_ID frame for <conn_id> CID of <qc> connection.
+ *
+ * Returns 1 on success else 0.
+ */
+int qc_build_new_connection_id_frm(struct quic_conn *qc,
+                                   struct quic_connection_id *conn_id)
+{
+       int ret = 0;
+       struct quic_frame *frm;
+       struct quic_enc_level *qel;
+
+       TRACE_ENTER(QUIC_EV_CONN_PRSHPKT, qc);
 
+       qel = qc->ael;
+       frm = qc_frm_alloc(QUIC_FT_NEW_CONNECTION_ID);
+       if (!frm) {
+               TRACE_ERROR("frame allocation error", QUIC_EV_CONN_IO_CB, qc);
+               goto leave;
+       }
+
+       quic_connection_id_to_frm_cpy(frm, conn_id);
+       LIST_APPEND(&qel->pktns->tx.frms, &frm->list);
+       ret = 1;
+ leave:
+       TRACE_LEAVE(QUIC_EV_CONN_PRSHPKT, qc);
+       return ret;
+}
index fe7746fa82d794d769a05d403143dc9a12937e59..9559eb4627145eff8f122a4830aae0b3f33b7c88 100644 (file)
@@ -396,35 +396,6 @@ int qc_h3_request_reject(struct quic_conn *qc, uint64_t id)
        return ret;
 }
 
-/* Build a NEW_CONNECTION_ID frame for <conn_id> CID of <qc> connection.
- *
- * Returns 1 on success else 0.
- */
-int qc_build_new_connection_id_frm(struct quic_conn *qc,
-                                   struct quic_connection_id *conn_id)
-{
-       int ret = 0;
-       struct quic_frame *frm;
-       struct quic_enc_level *qel;
-
-       TRACE_ENTER(QUIC_EV_CONN_PRSHPKT, qc);
-
-       qel = qc->ael;
-       frm = qc_frm_alloc(QUIC_FT_NEW_CONNECTION_ID);
-       if (!frm) {
-               TRACE_ERROR("frame allocation error", QUIC_EV_CONN_IO_CB, qc);
-               goto leave;
-       }
-
-       quic_connection_id_to_frm_cpy(frm, conn_id);
-       LIST_APPEND(&qel->pktns->tx.frms, &frm->list);
-       ret = 1;
- leave:
-       TRACE_LEAVE(QUIC_EV_CONN_PRSHPKT, qc);
-       return ret;
-}
-
-
 /* Remove a <qc> quic-conn from its ha_thread_ctx list. If <closing> is true,
  * it will immediately be reinserted in the ha_thread_ctx quic_conns_clo list.
  */