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,
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)
{
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.