]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: quic: Move the QUIC DCID parser to quic_sock.c
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 27 Nov 2023 11:01:36 +0000 (12:01 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 14:37:50 +0000 (15:37 +0100)
Move quic_get_dgram_dcid() from quic_conn.c to quic_sock.c because
only used in this file and define it as static.

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

index 9ff559646ced2e12d27be31e51f26e9924e52223..725633f3d57d8478c2095ce3cf9885b70501ed88 100644 (file)
@@ -191,8 +191,6 @@ 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 qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len);
-int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end,
-                        unsigned char **dcid, size_t *dcid_len);
 struct quic_cid quic_derive_cid(const struct quic_cid *orig,
                                 const struct sockaddr_storage *addr);
 int quic_get_cid_tid(const unsigned char *cid, size_t cid_len,
index 92d48fe2a344741f3a81bfa1d4563b8dcdc449bb..7f9837f8274b6dea154c443be0a4e01d71b15012 100644 (file)
@@ -1592,47 +1592,6 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
        return 0;
 }
 
-/* Retrieve the DCID from a QUIC datagram or packet at <pos> position,
- * <end> being at one byte past the end of this datagram.
- * Returns 1 if succeeded, 0 if not.
- */
-int quic_get_dgram_dcid(unsigned char *pos, const unsigned char *end,
-                        unsigned char **dcid, size_t *dcid_len)
-{
-       int ret = 0, long_header;
-       size_t minlen, skip;
-
-       TRACE_ENTER(QUIC_EV_CONN_RXPKT);
-
-       if (!(*pos & QUIC_PACKET_FIXED_BIT)) {
-               TRACE_PROTO("fixed bit not set", QUIC_EV_CONN_RXPKT);
-               goto err;
-       }
-
-       long_header = *pos & QUIC_PACKET_LONG_HEADER_BIT;
-       minlen = long_header ? QUIC_LONG_PACKET_MINLEN :
-               QUIC_SHORT_PACKET_MINLEN + QUIC_HAP_CID_LEN + QUIC_TLS_TAG_LEN;
-       skip = long_header ? QUIC_LONG_PACKET_DCID_OFF : QUIC_SHORT_PACKET_DCID_OFF;
-       if (end - pos < minlen)
-               goto err;
-
-       pos += skip;
-       *dcid_len = long_header ? *pos++ : QUIC_HAP_CID_LEN;
-       if (*dcid_len > QUIC_CID_MAXLEN || end - pos <= *dcid_len)
-               goto err;
-
-       *dcid = pos;
-
-       ret = 1;
- leave:
-       TRACE_LEAVE(QUIC_EV_CONN_RXPKT);
-       return ret;
-
- err:
-       TRACE_PROTO("wrong datagram", QUIC_EV_CONN_RXPKT);
-       goto leave;
-}
-
 /* Notify upper layer of a fatal error which forces to close the connection. */
 void qc_notify_err(struct quic_conn *qc)
 {
index 323fe6cbded3e4d6d9309acd6b74e7d088d9c517..c479249b74b23abeda341811fc0faf2eec478b4d 100644 (file)
@@ -208,6 +208,48 @@ struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state)
        return t;
 }
 
+/* Retrieve the DCID from a QUIC datagram or packet at <pos> position,
+ * <end> being at one byte past the end of this datagram.
+ * Returns 1 if succeeded, 0 if not.
+ */
+static int quic_get_dgram_dcid(unsigned char *pos, const unsigned char *end,
+                               unsigned char **dcid, size_t *dcid_len)
+{
+       int ret = 0, long_header;
+       size_t minlen, skip;
+
+       TRACE_ENTER(QUIC_EV_CONN_RXPKT);
+
+       if (!(*pos & QUIC_PACKET_FIXED_BIT)) {
+               TRACE_PROTO("fixed bit not set", QUIC_EV_CONN_RXPKT);
+               goto err;
+       }
+
+       long_header = *pos & QUIC_PACKET_LONG_HEADER_BIT;
+       minlen = long_header ? QUIC_LONG_PACKET_MINLEN :
+               QUIC_SHORT_PACKET_MINLEN + QUIC_HAP_CID_LEN + QUIC_TLS_TAG_LEN;
+       skip = long_header ? QUIC_LONG_PACKET_DCID_OFF : QUIC_SHORT_PACKET_DCID_OFF;
+       if (end - pos < minlen)
+               goto err;
+
+       pos += skip;
+       *dcid_len = long_header ? *pos++ : QUIC_HAP_CID_LEN;
+       if (*dcid_len > QUIC_CID_MAXLEN || end - pos <= *dcid_len)
+               goto err;
+
+       *dcid = pos;
+
+       ret = 1;
+ leave:
+       TRACE_LEAVE(QUIC_EV_CONN_RXPKT);
+       return ret;
+
+ err:
+       TRACE_PROTO("wrong datagram", QUIC_EV_CONN_RXPKT);
+       goto leave;
+}
+
+
 /* Retrieve the DCID from the datagram found at <pos> position and deliver it to the
  * correct datagram handler.
  * Return 1 if a correct datagram could be found, 0 if not.