Lines Matching refs:b

186 static int dgram_pair_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride,
189 static int dgram_pair_recvmmsg(BIO *b, BIO_MSG *msg, size_t stride,
194 static size_t dgram_pair_read_inner(struct bio_dgram_pair_st *b, uint8_t *buf,
273 #define is_dgram_pair(b) (b->peer != NULL) argument
277 struct bio_dgram_pair_st *b = OPENSSL_zalloc(sizeof(*b)); in dgram_pair_init() local
279 if (b == NULL) in dgram_pair_init()
282 b->mtu = 1472; /* conservative default MTU */ in dgram_pair_init()
284 b->req_buf_len = 9 * (sizeof(struct dgram_hdr) + b->mtu); in dgram_pair_init()
286 b->lock = CRYPTO_THREAD_lock_new(); in dgram_pair_init()
287 if (b->lock == NULL) { in dgram_pair_init()
288 OPENSSL_free(b); in dgram_pair_init()
292 bio->ptr = b; in dgram_pair_init()
298 struct bio_dgram_pair_st *b; in dgram_mem_init() local
303 b = bio->ptr; in dgram_mem_init()
305 if (ring_buf_init(&b->rbuf, b->req_buf_len) == 0) { in dgram_mem_init()
310 b->grows_on_write = 1; in dgram_mem_init()
318 struct bio_dgram_pair_st *b; in dgram_pair_free() local
323 b = bio->ptr; in dgram_pair_free()
324 if (!ossl_assert(b != NULL)) in dgram_pair_free()
330 CRYPTO_THREAD_lock_free(b->lock); in dgram_pair_free()
331 OPENSSL_free(b); in dgram_pair_free()
431 struct bio_dgram_pair_st *b = bio->ptr, *peerb; in dgram_pair_ctrl_eof() local
433 if (!ossl_assert(b != NULL)) in dgram_pair_ctrl_eof()
439 if (!is_dgram_pair(b)) in dgram_pair_ctrl_eof()
443 peerb = b->peer->ptr; in dgram_pair_ctrl_eof()
457 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_set_write_buf_size() local
460 if (b->peer != NULL) { in dgram_pair_ctrl_set_write_buf_size()
469 if (b->rbuf.start != NULL) { in dgram_pair_ctrl_set_write_buf_size()
470 if (!ring_buf_resize(&b->rbuf, len)) in dgram_pair_ctrl_set_write_buf_size()
474 b->req_buf_len = len; in dgram_pair_ctrl_set_write_buf_size()
475 b->grows_on_write = 0; in dgram_pair_ctrl_set_write_buf_size()
482 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_reset() local
484 ring_buf_clear(&b->rbuf); in dgram_pair_ctrl_reset()
492 struct bio_dgram_pair_st *b = bio->ptr, *readb; in dgram_pair_ctrl_pending() local
499 if (is_dgram_pair(b)) in dgram_pair_ctrl_pending()
500 readb = b->peer->ptr; in dgram_pair_ctrl_pending()
502 readb = b; in dgram_pair_ctrl_pending()
527 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_get_write_guarantee() local
529 if (CRYPTO_THREAD_read_lock(b->lock) == 0) in dgram_pair_ctrl_get_write_guarantee()
532 l = b->rbuf.len - b->rbuf.count; in dgram_pair_ctrl_get_write_guarantee()
540 if (l < b->mtu) in dgram_pair_ctrl_get_write_guarantee()
543 CRYPTO_THREAD_unlock(b->lock); in dgram_pair_ctrl_get_write_guarantee()
550 struct bio_dgram_pair_st *b = bio->ptr, *readb; in dgram_pair_ctrl_get_local_addr_cap() local
555 if (is_dgram_pair(b)) in dgram_pair_ctrl_get_local_addr_cap()
556 readb = b->peer->ptr; in dgram_pair_ctrl_get_local_addr_cap()
558 readb = b; in dgram_pair_ctrl_get_local_addr_cap()
567 struct bio_dgram_pair_st *b = bio->ptr, *peerb; in dgram_pair_ctrl_get_effective_caps() local
569 if (b->peer == NULL) in dgram_pair_ctrl_get_effective_caps()
572 peerb = b->peer->ptr; in dgram_pair_ctrl_get_effective_caps()
580 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_get_caps() local
582 return b->cap; in dgram_pair_ctrl_get_caps()
588 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_set_caps() local
590 b->cap = caps; in dgram_pair_ctrl_set_caps()
597 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_get_local_addr_enable() local
599 return b->local_addr_enable; in dgram_pair_ctrl_get_local_addr_enable()
605 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_set_local_addr_enable() local
610 b->local_addr_enable = (enable != 0 ? 1 : 0); in dgram_pair_ctrl_set_local_addr_enable()
617 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_ctrl_get_mtu() local
619 return b->mtu; in dgram_pair_ctrl_get_mtu()
625 struct bio_dgram_pair_st *b = bio->ptr, *peerb; in dgram_pair_ctrl_set_mtu() local
627 b->mtu = mtu; in dgram_pair_ctrl_set_mtu()
629 if (b->peer != NULL) { in dgram_pair_ctrl_set_mtu()
630 peerb = b->peer->ptr; in dgram_pair_ctrl_set_mtu()
641 struct bio_dgram_pair_st *b = bio->ptr; in dgram_mem_ctrl() local
643 if (!ossl_assert(b != NULL)) in dgram_mem_ctrl()
660 ret = (long)b->req_buf_len; in dgram_mem_ctrl()
689 ret = (long)b->no_trunc; in dgram_mem_ctrl()
694 b->no_trunc = (num > 0); in dgram_mem_ctrl()
831 static size_t dgram_pair_read_inner(struct bio_dgram_pair_st *b, uint8_t *buf, size_t sz) in dgram_pair_read_inner() argument
849 ring_buf_tail(&b->rbuf, &src_buf, &src_len); in dgram_pair_read_inner()
859 ring_buf_pop(&b->rbuf, src_len); in dgram_pair_read_inner()
879 struct bio_dgram_pair_st *b = bio->ptr, *readb; in dgram_pair_read_actual() local
888 if (!ossl_assert(b != NULL)) in dgram_pair_read_actual()
891 if (is_dgram_pair(b)) in dgram_pair_read_actual()
892 readb = b->peer->ptr; in dgram_pair_read_actual()
894 readb = b; in dgram_pair_read_actual()
902 if (local != NULL && b->local_addr_enable == 0) in dgram_pair_read_actual()
928 if (b->no_trunc) { in dgram_pair_read_actual()
959 struct bio_dgram_pair_st *b) in dgram_pair_lock_both_write() argument
963 x = (a->role == 1) ? a : b; in dgram_pair_lock_both_write()
964 y = (a->role == 1) ? b : a; in dgram_pair_lock_both_write()
966 if (!ossl_assert(a->role != b->role)) in dgram_pair_lock_both_write()
969 if (!ossl_assert(a != b && x != y)) in dgram_pair_lock_both_write()
984 struct bio_dgram_pair_st *b) in dgram_pair_unlock_both() argument
987 CRYPTO_THREAD_unlock(b->lock); in dgram_pair_unlock_both()
995 struct bio_dgram_pair_st *b = bio->ptr, *peerb; in dgram_pair_read() local
1002 if (b->peer == NULL) { in dgram_pair_read()
1007 peerb = b->peer->ptr; in dgram_pair_read()
1014 if (dgram_pair_lock_both_write(peerb, b) == 0) { in dgram_pair_read()
1028 dgram_pair_unlock_both(peerb, b); in dgram_pair_read()
1042 struct bio_dgram_pair_st *b = bio->ptr, *readb; in dgram_pair_recvmmsg() local
1055 if (is_dgram_pair(b)) in dgram_pair_recvmmsg()
1056 readb = b->peer->ptr; in dgram_pair_recvmmsg()
1058 readb = b; in dgram_pair_recvmmsg()
1097 struct bio_dgram_pair_st *b = bio->ptr; in dgram_mem_read() local
1104 if (CRYPTO_THREAD_write_lock(b->lock) == 0) { in dgram_mem_read()
1118 CRYPTO_THREAD_unlock(b->lock); in dgram_mem_read()
1151 static size_t dgram_pair_write_inner(struct bio_dgram_pair_st *b, in dgram_pair_write_inner() argument
1169 ring_buf_head(&b->rbuf, &dst_buf, &dst_len); in dgram_pair_write_inner()
1173 if (!b->grows_on_write) /* resize only if size not set explicitly */ in dgram_pair_write_inner()
1176 new_len = compute_rbuf_growth(b->req_buf_len + sz, b->req_buf_len); in dgram_pair_write_inner()
1177 if (new_len == 0 || !ring_buf_resize(&b->rbuf, new_len)) in dgram_pair_write_inner()
1179 b->req_buf_len = new_len; in dgram_pair_write_inner()
1186 ring_buf_push(&b->rbuf, dst_len); in dgram_pair_write_inner()
1206 struct bio_dgram_pair_st *b = bio->ptr, *readb; in dgram_pair_write_actual() local
1215 if (!ossl_assert(b != NULL && b->rbuf.start != NULL)) in dgram_pair_write_actual()
1221 if (local != NULL && b->local_addr_enable == 0) in dgram_pair_write_actual()
1224 if (is_dgram_pair(b)) in dgram_pair_write_actual()
1225 readb = b->peer->ptr; in dgram_pair_write_actual()
1227 readb = b; in dgram_pair_write_actual()
1235 saved_idx = b->rbuf.idx[0]; in dgram_pair_write_actual()
1236 saved_count = b->rbuf.count; in dgram_pair_write_actual()
1237 if (dgram_pair_write_inner(b, (const uint8_t *)&hdr, sizeof(hdr)) != sizeof(hdr) in dgram_pair_write_actual()
1238 || dgram_pair_write_inner(b, (const uint8_t *)buf, sz) != sz) { in dgram_pair_write_actual()
1243 b->rbuf.idx[0] = saved_idx; in dgram_pair_write_actual()
1244 b->rbuf.count = saved_count; in dgram_pair_write_actual()
1258 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_write() local
1265 if (CRYPTO_THREAD_write_lock(b->lock) == 0) { in dgram_pair_write()
1278 CRYPTO_THREAD_unlock(b->lock); in dgram_pair_write()
1290 struct bio_dgram_pair_st *b = bio->ptr; in dgram_pair_sendmmsg() local
1297 if (CRYPTO_THREAD_write_lock(b->lock) == 0) { in dgram_pair_sendmmsg()
1324 CRYPTO_THREAD_unlock(b->lock); in dgram_pair_sendmmsg()