Lines Matching refs:cf

1000 static void cf_socket_close(struct Curl_cfilter *cf, struct Curl_easy *data)  in cf_socket_close()  argument
1002 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_close()
1005 CURL_TRC_CF(data, cf, "cf_socket_close(%" FMT_SOCKET_T ")", ctx->sock); in cf_socket_close()
1006 if(ctx->sock == cf->conn->sock[cf->sockindex]) in cf_socket_close()
1007 cf->conn->sock[cf->sockindex] = CURL_SOCKET_BAD; in cf_socket_close()
1008 socket_close(data, cf->conn, !ctx->accepted, ctx->sock); in cf_socket_close()
1010 if(ctx->active && cf->sockindex == FIRSTSOCKET) in cf_socket_close()
1011 cf->conn->remote_addr = NULL; in cf_socket_close()
1017 cf->connected = FALSE; in cf_socket_close()
1020 static CURLcode cf_socket_shutdown(struct Curl_cfilter *cf, in cf_socket_shutdown() argument
1024 if(cf->connected) { in cf_socket_shutdown()
1025 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_shutdown()
1027 CURL_TRC_CF(data, cf, "cf_socket_shutdown(%" FMT_SOCKET_T ")", ctx->sock); in cf_socket_shutdown()
1042 static void cf_socket_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) in cf_socket_destroy() argument
1044 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_destroy()
1046 cf_socket_close(cf, data); in cf_socket_destroy()
1047 CURL_TRC_CF(data, cf, "destroy"); in cf_socket_destroy()
1049 cf->ctx = NULL; in cf_socket_destroy()
1052 static CURLcode set_local_ip(struct Curl_cfilter *cf, in set_local_ip() argument
1055 struct cf_socket_ctx *ctx = cf->ctx; in set_local_ip()
1088 static CURLcode set_remote_ip(struct Curl_cfilter *cf, in set_remote_ip() argument
1091 struct cf_socket_ctx *ctx = cf->ctx; in set_remote_ip()
1108 static CURLcode cf_socket_open(struct Curl_cfilter *cf, in cf_socket_open() argument
1111 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_open()
1137 result = set_remote_ip(cf, data); in cf_socket_open()
1191 result = bindlocal(data, cf->conn, ctx->sock, ctx->addr.family, in cf_socket_open()
1229 socket_close(data, cf->conn, TRUE, ctx->sock); in cf_socket_open()
1234 set_local_ip(cf, data); in cf_socket_open()
1236 cf->connected = TRUE; in cf_socket_open()
1238 CURL_TRC_CF(data, cf, "cf_socket_open() -> %d, fd=%" FMT_SOCKET_T, in cf_socket_open()
1243 static int do_connect(struct Curl_cfilter *cf, struct Curl_easy *data, in do_connect() argument
1246 struct cf_socket_ctx *ctx = cf->ctx; in do_connect()
1285 if(cf->conn->given->flags & PROTOPT_SSL) in do_connect()
1298 static CURLcode cf_tcp_connect(struct Curl_cfilter *cf, in cf_tcp_connect() argument
1302 struct cf_socket_ctx *ctx = cf->ctx; in cf_tcp_connect()
1307 if(cf->connected) { in cf_tcp_connect()
1320 result = cf_socket_open(cf, data); in cf_tcp_connect()
1324 if(cf->connected) { in cf_tcp_connect()
1330 rc = do_connect(cf, data, cf->conn->bits.tcp_fastopen); in cf_tcp_connect()
1332 set_local_ip(cf, data); in cf_tcp_connect()
1333 CURL_TRC_CF(data, cf, "local address %s port %d...", in cf_tcp_connect()
1352 CURL_TRC_CF(data, cf, "not connected yet"); in cf_tcp_connect()
1355 else if(rc == CURL_CSELECT_OUT || cf->conn->bits.tcp_fastopen) { in cf_tcp_connect()
1359 set_local_ip(cf, data); in cf_tcp_connect()
1361 cf->connected = TRUE; in cf_tcp_connect()
1362 CURL_TRC_CF(data, cf, "connected"); in cf_tcp_connect()
1374 set_local_ip(cf, data); in cf_tcp_connect()
1388 socket_close(data, cf->conn, TRUE, ctx->sock); in cf_tcp_connect()
1396 static void cf_socket_get_host(struct Curl_cfilter *cf, in cf_socket_get_host() argument
1402 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_get_host()
1404 *phost = cf->conn->host.name; in cf_socket_get_host()
1405 *pdisplay_host = cf->conn->host.dispname; in cf_socket_get_host()
1409 static void cf_socket_adjust_pollset(struct Curl_cfilter *cf, in cf_socket_adjust_pollset() argument
1413 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_adjust_pollset()
1422 CURL_TRC_CF(data, cf, "adjust_pollset, listening, POLLIN fd=%" in cf_socket_adjust_pollset()
1425 else if(!cf->connected) { in cf_socket_adjust_pollset()
1427 CURL_TRC_CF(data, cf, "adjust_pollset, !connected, POLLOUT fd=%" in cf_socket_adjust_pollset()
1432 CURL_TRC_CF(data, cf, "adjust_pollset, !active, POLLIN fd=%" in cf_socket_adjust_pollset()
1438 static bool cf_socket_data_pending(struct Curl_cfilter *cf, in cf_socket_data_pending() argument
1441 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_data_pending()
1475 static ssize_t cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data, in cf_socket_send() argument
1479 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_send()
1486 fdsave = cf->conn->sock[cf->sockindex]; in cf_socket_send()
1487 cf->conn->sock[cf->sockindex] = ctx->sock; in cf_socket_send()
1495 CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE EWOULDBLOCK", orig_len); in cf_socket_send()
1498 cf->conn->sock[cf->sockindex] = fdsave; in cf_socket_send()
1502 if(cf->cft != &Curl_cft_udp && ctx->wpartial_percent > 0 && len > 8) { in cf_socket_send()
1506 CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE partial write of %zu bytes", in cf_socket_send()
1512 if(cf->conn->bits.tcp_fastopen) { in cf_socket_send()
1514 &cf->conn->remote_addr->curl_sa_addr, in cf_socket_send()
1515 cf->conn->remote_addr->addrlen); in cf_socket_send()
1516 cf->conn->bits.tcp_fastopen = FALSE; in cf_socket_send()
1554 CURL_TRC_CF(data, cf, "send(len=%zu) -> %d, err=%d", in cf_socket_send()
1556 cf->conn->sock[cf->sockindex] = fdsave; in cf_socket_send()
1560 static ssize_t cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data, in cf_socket_recv() argument
1563 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_recv()
1570 if(cf->cft != &Curl_cft_udp && ctx->rblock_percent > 0) { in cf_socket_recv()
1574 CURL_TRC_CF(data, cf, "recv(len=%zu) SIMULATE EWOULDBLOCK", len); in cf_socket_recv()
1579 if(cf->cft != &Curl_cft_udp && ctx->recv_max && ctx->recv_max < len) { in cf_socket_recv()
1582 CURL_TRC_CF(data, cf, "recv(len=%zu) SIMULATE max read of %zu bytes", in cf_socket_recv()
1617 CURL_TRC_CF(data, cf, "recv(len=%zu) -> %d, err=%d", len, (int)nread, in cf_socket_recv()
1626 static void cf_socket_update_data(struct Curl_cfilter *cf, in cf_socket_update_data() argument
1630 if(cf->connected && (cf->sockindex == FIRSTSOCKET)) { in cf_socket_update_data()
1631 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_update_data()
1634 data->info.conn_remote_port = cf->conn->remote_port; in cf_socket_update_data()
1638 static void cf_socket_active(struct Curl_cfilter *cf, struct Curl_easy *data) in cf_socket_active() argument
1640 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_active()
1643 cf->conn->sock[cf->sockindex] = ctx->sock; in cf_socket_active()
1644 set_local_ip(cf, data); in cf_socket_active()
1645 if(cf->sockindex == FIRSTSOCKET) { in cf_socket_active()
1646 cf->conn->primary = ctx->ip; in cf_socket_active()
1647 cf->conn->remote_addr = &ctx->addr; in cf_socket_active()
1649 cf->conn->bits.ipv6 = (ctx->addr.family == AF_INET6); in cf_socket_active()
1653 cf->conn->secondary = ctx->ip; in cf_socket_active()
1658 static CURLcode cf_socket_cntrl(struct Curl_cfilter *cf, in cf_socket_cntrl() argument
1662 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_cntrl()
1668 cf_socket_active(cf, data); in cf_socket_cntrl()
1669 cf_socket_update_data(cf, data); in cf_socket_cntrl()
1672 cf_socket_update_data(cf, data); in cf_socket_cntrl()
1681 static bool cf_socket_conn_is_alive(struct Curl_cfilter *cf, in cf_socket_conn_is_alive() argument
1685 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_conn_is_alive()
1701 CURL_TRC_CF(data, cf, "is_alive: poll error, assume dead"); in cf_socket_conn_is_alive()
1705 CURL_TRC_CF(data, cf, "is_alive: poll timeout, assume alive"); in cf_socket_conn_is_alive()
1709 CURL_TRC_CF(data, cf, "is_alive: err/hup/etc events, assume dead"); in cf_socket_conn_is_alive()
1713 CURL_TRC_CF(data, cf, "is_alive: valid events, looks alive"); in cf_socket_conn_is_alive()
1718 static CURLcode cf_socket_query(struct Curl_cfilter *cf, in cf_socket_query() argument
1722 struct cf_socket_ctx *ctx = cf->ctx; in cf_socket_query()
1766 return cf->next ? in cf_socket_query()
1767 cf->next->cft->query(cf->next, data, query, pres1, pres2) : in cf_socket_query()
1797 struct Curl_cfilter *cf = NULL; in Curl_cf_tcp_create() local
1810 result = Curl_cf_create(&cf, &Curl_cft_tcp, ctx); in Curl_cf_tcp_create()
1813 *pcf = (!result) ? cf : NULL; in Curl_cf_tcp_create()
1815 Curl_safefree(cf); in Curl_cf_tcp_create()
1822 static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf, in cf_udp_setup_quic() argument
1825 struct cf_socket_ctx *ctx = cf->ctx; in cf_udp_setup_quic()
1840 set_local_ip(cf, data); in cf_udp_setup_quic()
1841 CURL_TRC_CF(data, cf, "%s socket %" FMT_SOCKET_T in cf_udp_setup_quic()
1881 static CURLcode cf_udp_connect(struct Curl_cfilter *cf, in cf_udp_connect() argument
1885 struct cf_socket_ctx *ctx = cf->ctx; in cf_udp_connect()
1889 if(cf->connected) { in cf_udp_connect()
1895 result = cf_socket_open(cf, data); in cf_udp_connect()
1897 CURL_TRC_CF(data, cf, "cf_udp_connect(), open failed -> %d", result); in cf_udp_connect()
1902 result = cf_udp_setup_quic(cf, data); in cf_udp_connect()
1905 CURL_TRC_CF(data, cf, "cf_udp_connect(), opened socket=%" in cf_udp_connect()
1910 CURL_TRC_CF(data, cf, "cf_udp_connect(), opened socket=%" in cf_udp_connect()
1914 cf->connected = TRUE; in cf_udp_connect()
1946 struct Curl_cfilter *cf = NULL; in Curl_cf_udp_create() local
1959 result = Curl_cf_create(&cf, &Curl_cft_udp, ctx); in Curl_cf_udp_create()
1962 *pcf = (!result) ? cf : NULL; in Curl_cf_udp_create()
1964 Curl_safefree(cf); in Curl_cf_udp_create()
1998 struct Curl_cfilter *cf = NULL; in Curl_cf_unix_create() local
2011 result = Curl_cf_create(&cf, &Curl_cft_unix, ctx); in Curl_cf_unix_create()
2014 *pcf = (!result) ? cf : NULL; in Curl_cf_unix_create()
2016 Curl_safefree(cf); in Curl_cf_unix_create()
2023 static timediff_t cf_tcp_accept_timeleft(struct Curl_cfilter *cf, in cf_tcp_accept_timeleft() argument
2026 struct cf_socket_ctx *ctx = cf->ctx; in cf_tcp_accept_timeleft()
2053 static void cf_tcp_set_accepted_remote_ip(struct Curl_cfilter *cf, in cf_tcp_set_accepted_remote_ip() argument
2056 struct cf_socket_ctx *ctx = cf->ctx; in cf_tcp_set_accepted_remote_ip()
2085 static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf, in cf_tcp_accept_connect() argument
2089 struct cf_socket_ctx *ctx = cf->ctx; in cf_tcp_accept_connect()
2104 if(cf->connected) { in cf_tcp_accept_connect()
2109 timeout_ms = cf_tcp_accept_timeleft(cf, data); in cf_tcp_accept_connect()
2116 CURL_TRC_CF(data, cf, "Checking for incoming on fd=%" FMT_SOCKET_T in cf_tcp_accept_connect()
2120 CURL_TRC_CF(data, cf, "socket_check -> %x", socketstate); in cf_tcp_accept_connect()
2135 CURL_TRC_CF(data, cf, "nothing heard from the server yet"); in cf_tcp_accept_connect()
2155 socket_close(data, cf->conn, TRUE, ctx->sock); in cf_tcp_accept_connect()
2158 cf->conn->sock[cf->sockindex] = ctx->sock; in cf_tcp_accept_connect()
2159 cf_tcp_set_accepted_remote_ip(cf, data); in cf_tcp_accept_connect()
2160 set_local_ip(cf, data); in cf_tcp_accept_connect()
2163 cf->connected = TRUE; in cf_tcp_accept_connect()
2164 CURL_TRC_CF(data, cf, "accepted_set(sock=%" FMT_SOCKET_T in cf_tcp_accept_connect()
2207 struct Curl_cfilter *cf = NULL; in Curl_conn_tcp_listen_set() local
2223 result = Curl_cf_create(&cf, &Curl_cft_tcp_accept, ctx); in Curl_conn_tcp_listen_set()
2226 Curl_conn_cf_add(data, conn, sockindex, cf); in Curl_conn_tcp_listen_set()
2230 set_local_ip(cf, data); in Curl_conn_tcp_listen_set()
2231 CURL_TRC_CF(data, cf, "set filter for listen socket fd=%" FMT_SOCKET_T in Curl_conn_tcp_listen_set()
2237 Curl_safefree(cf); in Curl_conn_tcp_listen_set()
2246 struct Curl_cfilter *cf = data->conn->cfilter[sockindex]; in Curl_conn_is_tcp_listen() local
2247 while(cf) { in Curl_conn_is_tcp_listen()
2248 if(cf->cft == &Curl_cft_tcp_accept) in Curl_conn_is_tcp_listen()
2250 cf = cf->next; in Curl_conn_is_tcp_listen()
2258 static bool cf_is_socket(struct Curl_cfilter *cf) in cf_is_socket() argument
2260 return cf && (cf->cft == &Curl_cft_tcp || in cf_is_socket()
2261 cf->cft == &Curl_cft_udp || in cf_is_socket()
2262 cf->cft == &Curl_cft_unix || in cf_is_socket()
2263 cf->cft == &Curl_cft_tcp_accept); in cf_is_socket()
2266 CURLcode Curl_cf_socket_peek(struct Curl_cfilter *cf, in Curl_cf_socket_peek() argument
2273 if(cf_is_socket(cf) && cf->ctx) { in Curl_cf_socket_peek()
2274 struct cf_socket_ctx *ctx = cf->ctx; in Curl_cf_socket_peek()