Lines Matching refs:conn
63 APP_CONN *conn; in new_conn() local
71 conn = calloc(1, sizeof(APP_CONN)); in new_conn()
72 if (conn == NULL) in new_conn()
77 free(conn); in new_conn()
83 free(conn); in new_conn()
90 free(conn); in new_conn()
98 free(conn); in new_conn()
106 free(conn); in new_conn()
113 free(conn); in new_conn()
122 free(conn); in new_conn()
130 conn->ssl_bio = out; in new_conn()
131 return conn; in new_conn()
140 int tx(APP_CONN *conn, const void *buf, int buf_len) in tx() argument
144 conn->tx_need_rx = 0; in tx()
146 l = BIO_write(conn->ssl_bio, buf, buf_len); in tx()
148 if (BIO_should_retry(conn->ssl_bio)) { in tx()
149 conn->tx_need_rx = BIO_should_read(conn->ssl_bio); in tx()
165 int rx(APP_CONN *conn, void *buf, int buf_len) in rx() argument
169 conn->rx_need_tx = 0; in rx()
171 l = BIO_read(conn->ssl_bio, buf, buf_len); in rx()
173 if (BIO_should_retry(conn->ssl_bio)) { in rx()
174 conn->rx_need_tx = BIO_should_write(conn->ssl_bio); in rx()
188 int get_conn_fd(APP_CONN *conn) in get_conn_fd() argument
193 if (!BIO_get_rpoll_descriptor(conn->ssl_bio, &d)) in get_conn_fd()
198 return BIO_get_fd(conn->ssl_bio, NULL); in get_conn_fd()
215 int get_conn_pending_tx(APP_CONN *conn) in get_conn_pending_tx() argument
218 return (SSL_net_read_desired(conn->ssl) ? POLLIN : 0) in get_conn_pending_tx()
219 | (SSL_net_write_desired(conn->ssl) ? POLLOUT : 0) in get_conn_pending_tx()
222 return (conn->tx_need_rx ? POLLIN : 0) | POLLOUT | POLLERR; in get_conn_pending_tx()
226 int get_conn_pending_rx(APP_CONN *conn) in get_conn_pending_rx() argument
229 return get_conn_pending_tx(conn); in get_conn_pending_rx()
231 return (conn->rx_need_tx ? POLLOUT : 0) | POLLIN | POLLERR; in get_conn_pending_rx()
239 void teardown(APP_CONN *conn) in teardown() argument
241 BIO_free_all(conn->ssl_bio); in teardown()
242 free(conn); in teardown()
266 APP_CONN *conn = NULL; in main() local
284 conn = new_conn(ctx, host_port); in main()
285 if (conn == NULL) { in main()
292 l = tx(conn, tx_p, tx_len); in main()
300 pfd.fd = get_conn_fd(conn); in main()
301 pfd.events = get_conn_pending_tx(conn); in main()
311 l = rx(conn, rx_buf, sizeof(rx_buf)); in main()
318 pfd.fd = get_conn_fd(conn); in main()
319 pfd.events = get_conn_pending_rx(conn); in main()
329 if (conn != NULL) in main()
330 teardown(conn); in main()