]>
git.ipfire.org Git - thirdparty/openssl.git/blob - ssl/quic/quic_record_rx_wrap.c
2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "internal/cryptlib.h"
11 #include "internal/refcount.h"
12 #include "quic_record_rx_wrap.h"
14 OSSL_QRX_PKT_WRAP
*ossl_qrx_pkt_wrap_new(OSSL_QRX_PKT
*pkt
)
16 CRYPTO_RWLOCK
*refcount_lock
= NULL
;
17 OSSL_QRX_PKT_WRAP
*res
= NULL
;
23 refcount_lock
= CRYPTO_THREAD_lock_new();
24 if (refcount_lock
== NULL
) {
25 ERR_raise(ERR_LIB_SSL
, ERR_R_CRYPTO_LIB
);
30 if ((res
= OPENSSL_zalloc(sizeof(*res
))) == NULL
) {
31 CRYPTO_THREAD_lock_free(refcount_lock
);
36 res
->handle
= pkt
->handle
;
38 res
->lock
= refcount_lock
;
43 int ossl_qrx_pkt_wrap_up_ref(OSSL_QRX_PKT_WRAP
*pkt_wrap
)
47 if (pkt_wrap
== NULL
|| pkt_wrap
->pkt
== NULL
)
49 CRYPTO_UP_REF(&pkt_wrap
->references
, &ref
, pkt_wrap
->lock
);
53 void ossl_qrx_pkt_wrap_free(OSSL_QRX
*qrx
, OSSL_QRX_PKT_WRAP
*pkt_wrap
)
59 CRYPTO_DOWN_REF(&pkt_wrap
->references
, &ref
, pkt_wrap
->lock
);
62 ossl_qrx_release_pkt(qrx
, pkt_wrap
->handle
);
63 CRYPTO_THREAD_lock_free(pkt_wrap
->lock
);
64 OPENSSL_free(pkt_wrap
);