Lines Matching refs:cf

82 static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,  in tunnel_stream_init()  argument
96 result = Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip); in tunnel_stream_init()
119 static void h2_tunnel_go_state(struct Curl_cfilter *cf, in h2_tunnel_go_state() argument
124 (void)cf; in h2_tunnel_go_state()
139 CURL_TRC_CF(data, cf, "[%d] new tunnel state 'init'", ts->stream_id); in h2_tunnel_go_state()
144 CURL_TRC_CF(data, cf, "[%d] new tunnel state 'connect'", ts->stream_id); in h2_tunnel_go_state()
149 CURL_TRC_CF(data, cf, "[%d] new tunnel state 'response'", ts->stream_id); in h2_tunnel_go_state()
154 CURL_TRC_CF(data, cf, "[%d] new tunnel state 'established'", in h2_tunnel_go_state()
162 CURL_TRC_CF(data, cf, "[%d] new tunnel state 'failed'", ts->stream_id); in h2_tunnel_go_state()
191 #define CF_CTX_CALL_DATA(cf) \ argument
192 ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
216 static void drain_tunnel(struct Curl_cfilter *cf, in drain_tunnel() argument
220 struct cf_h2_proxy_ctx *ctx = cf->ctx; in drain_tunnel()
223 (void)cf; in drain_tunnel()
229 CURL_TRC_CF(data, cf, "[%d] DRAIN select_bits=%x", in drain_tunnel()
240 struct Curl_cfilter *cf = reader_ctx; in proxy_nw_in_reader() local
243 if(cf) { in proxy_nw_in_reader()
244 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_nw_in_reader()
245 nread = Curl_conn_cf_recv(cf->next, data, (char *)buf, buflen, err); in proxy_nw_in_reader()
246 CURL_TRC_CF(data, cf, "[0] nw_in_reader(len=%zu) -> %zd, %d", in proxy_nw_in_reader()
259 struct Curl_cfilter *cf = writer_ctx; in proxy_h2_nw_out_writer() local
262 if(cf) { in proxy_h2_nw_out_writer()
263 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_h2_nw_out_writer()
264 nwritten = Curl_conn_cf_send(cf->next, data, (const char *)buf, buflen, in proxy_h2_nw_out_writer()
266 CURL_TRC_CF(data, cf, "[0] nw_out_writer(len=%zu) -> %zd, %d", in proxy_h2_nw_out_writer()
275 static int proxy_h2_client_new(struct Curl_cfilter *cf, in proxy_h2_client_new() argument
278 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_client_new()
294 rc = nghttp2_session_client_new3(&ctx->h2, cbs, cf, o, &mem); in proxy_h2_client_new()
326 static CURLcode cf_h2_proxy_ctx_init(struct Curl_cfilter *cf, in cf_h2_proxy_ctx_init() argument
329 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_ctx_init()
340 if(tunnel_stream_init(cf, &ctx->tunnel)) in cf_h2_proxy_ctx_init()
363 rc = proxy_h2_client_new(cf, cbs); in cf_h2_proxy_ctx_init()
403 CURL_TRC_CF(data, cf, "[0] init proxy ctx -> %d", result); in cf_h2_proxy_ctx_init()
413 static CURLcode proxy_h2_nw_out_flush(struct Curl_cfilter *cf, in proxy_h2_nw_out_flush() argument
416 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_nw_out_flush()
424 nwritten = Curl_bufq_pass(&ctx->outbufq, proxy_h2_nw_out_writer, cf, in proxy_h2_nw_out_flush()
428 CURL_TRC_CF(data, cf, "[0] flush nw send buffer(%zu) -> EAGAIN", in proxy_h2_nw_out_flush()
434 CURL_TRC_CF(data, cf, "[0] nw send buffer flushed"); in proxy_h2_nw_out_flush()
443 static int proxy_h2_process_pending_input(struct Curl_cfilter *cf, in proxy_h2_process_pending_input() argument
447 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_process_pending_input()
455 CURL_TRC_CF(data, cf, "[0] %zu bytes to nghttp2 -> %zd", blen, rv); in proxy_h2_process_pending_input()
465 CURL_TRC_CF(data, cf, "[0] all data in connection buffer processed"); in proxy_h2_process_pending_input()
469 CURL_TRC_CF(data, cf, "[0] process_pending_input: %zu bytes left " in proxy_h2_process_pending_input()
477 static CURLcode proxy_h2_progress_ingress(struct Curl_cfilter *cf, in proxy_h2_progress_ingress() argument
480 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_progress_ingress()
486 CURL_TRC_CF(data, cf, "[0] process %zu bytes in connection buffer", in proxy_h2_progress_ingress()
488 if(proxy_h2_process_pending_input(cf, data, &result) < 0) in proxy_h2_progress_ingress()
499 nread = Curl_bufq_slurp(&ctx->inbufq, proxy_nw_in_reader, cf, &result); in proxy_h2_progress_ingress()
500 CURL_TRC_CF(data, cf, "[0] read %zu bytes nw data -> %zd, %d", in proxy_h2_progress_ingress()
514 if(proxy_h2_process_pending_input(cf, data, &result)) in proxy_h2_progress_ingress()
519 connclose(cf->conn, "GOAWAY received"); in proxy_h2_progress_ingress()
525 static CURLcode proxy_h2_progress_egress(struct Curl_cfilter *cf, in proxy_h2_progress_egress() argument
528 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_progress_egress()
536 CURL_TRC_CF(data, cf, "[0] nghttp2_session_send error (%s)%d", in proxy_h2_progress_egress()
540 return proxy_h2_nw_out_flush(cf, data); in proxy_h2_progress_egress()
547 struct Curl_cfilter *cf = userp; in on_session_send() local
548 struct cf_h2_proxy_ctx *ctx = cf->ctx; in on_session_send()
549 struct Curl_easy *data = CF_DATA_CURRENT(cf); in on_session_send()
558 proxy_h2_nw_out_writer, cf, &result); in on_session_send()
648 struct Curl_cfilter *cf = userp; in proxy_h2_on_frame_send() local
649 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_h2_on_frame_send()
653 if(data && Curl_trc_cf_is_verbose(cf, data)) { in proxy_h2_on_frame_send()
658 CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer); in proxy_h2_on_frame_send()
668 struct Curl_cfilter *cf = userp; in proxy_h2_on_frame_recv() local
669 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_frame_recv()
670 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_h2_on_frame_recv()
676 if(Curl_trc_cf_is_verbose(cf, data)) { in proxy_h2_on_frame_recv()
681 CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer); in proxy_h2_on_frame_recv()
696 drain_tunnel(cf, data, &ctx->tunnel); in proxy_h2_on_frame_recv()
709 CURL_TRC_CF(data, cf, "[%d] rcvd FRAME not for tunnel", stream_id); in proxy_h2_on_frame_recv()
721 CURL_TRC_CF(data, cf, "[%d] got http status: %d", in proxy_h2_on_frame_recv()
731 drain_tunnel(cf, data, &ctx->tunnel); in proxy_h2_on_frame_recv()
747 struct Curl_cfilter *cf = userp; in proxy_h2_on_header() local
748 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_header()
749 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_h2_on_header()
758 CURL_TRC_CF(data, cf, "[%d] header for non-tunnel stream: " in proxy_h2_on_header()
788 CURL_TRC_CF(data, cf, "[%d] status: HTTP/2 %03d", in proxy_h2_on_header()
802 CURL_TRC_CF(data, cf, "[%d] header: %.*s: %.*s", in proxy_h2_on_header()
815 struct Curl_cfilter *cf = userp; in tunnel_send_callback() local
816 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_send_callback()
817 struct Curl_easy *data = CF_DATA_CURRENT(cf); in tunnel_send_callback()
843 CURL_TRC_CF(data, cf, "[%d] tunnel_send_callback -> %zd", in tunnel_send_callback()
852 struct Curl_cfilter *cf = userp; in tunnel_recv_callback() local
853 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_recv_callback()
878 struct Curl_cfilter *cf = userp; in proxy_h2_on_stream_close() local
879 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_stream_close()
880 struct Curl_easy *data = CF_DATA_CURRENT(cf); in proxy_h2_on_stream_close()
888 CURL_TRC_CF(data, cf, "[%d] proxy_h2_on_stream_close, %s (err %d)", in proxy_h2_on_stream_close()
897 struct Curl_cfilter *cf, in proxy_h2_submit() argument
912 (void)cf; in proxy_h2_submit()
952 static CURLcode submit_CONNECT(struct Curl_cfilter *cf, in submit_CONNECT() argument
956 struct cf_h2_proxy_ctx *ctx = cf->ctx; in submit_CONNECT()
960 result = Curl_http_proxy_create_CONNECT(&req, cf, data, 2); in submit_CONNECT()
969 result = proxy_h2_submit(&ts->stream_id, cf, data, ctx->h2, req, in submit_CONNECT()
970 NULL, ts, tunnel_send_callback, cf); in submit_CONNECT()
972 CURL_TRC_CF(data, cf, "[%d] send, nghttp2_submit_request error: %s", in submit_CONNECT()
984 static CURLcode inspect_response(struct Curl_cfilter *cf, in inspect_response() argument
990 (void)cf; in inspect_response()
995 h2_tunnel_go_state(cf, ts, H2_TUNNEL_ESTABLISHED, data); in inspect_response()
1007 CURL_TRC_CF(data, cf, "[0] CONNECT: fwd auth header '%s'", in inspect_response()
1016 h2_tunnel_go_state(cf, ts, H2_TUNNEL_INIT, data); in inspect_response()
1025 static CURLcode H2_CONNECT(struct Curl_cfilter *cf, in H2_CONNECT() argument
1029 struct cf_h2_proxy_ctx *ctx = cf->ctx; in H2_CONNECT()
1038 CURL_TRC_CF(data, cf, "[0] CONNECT start for %s", ts->authority); in H2_CONNECT()
1039 result = submit_CONNECT(cf, data, ts); in H2_CONNECT()
1042 h2_tunnel_go_state(cf, ts, H2_TUNNEL_CONNECT, data); in H2_CONNECT()
1047 result = proxy_h2_progress_ingress(cf, data); in H2_CONNECT()
1049 result = proxy_h2_progress_egress(cf, data); in H2_CONNECT()
1051 h2_tunnel_go_state(cf, ts, H2_TUNNEL_FAILED, data); in H2_CONNECT()
1056 h2_tunnel_go_state(cf, ts, H2_TUNNEL_RESPONSE, data); in H2_CONNECT()
1066 result = inspect_response(cf, data, ts); in H2_CONNECT()
1085 h2_tunnel_go_state(cf, ts, H2_TUNNEL_FAILED, data); in H2_CONNECT()
1089 static CURLcode cf_h2_proxy_connect(struct Curl_cfilter *cf, in cf_h2_proxy_connect() argument
1093 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_connect()
1099 if(cf->connected) { in cf_h2_proxy_connect()
1105 if(!cf->next->connected) { in cf_h2_proxy_connect()
1106 result = Curl_conn_cf_connect(cf->next, data, blocking, done); in cf_h2_proxy_connect()
1113 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_connect()
1115 result = cf_h2_proxy_ctx_init(cf, data); in cf_h2_proxy_connect()
1131 result = H2_CONNECT(cf, data, ts); in cf_h2_proxy_connect()
1136 cf->connected = TRUE; in cf_h2_proxy_connect()
1141 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_connect()
1145 static void cf_h2_proxy_close(struct Curl_cfilter *cf, struct Curl_easy *data) in cf_h2_proxy_close() argument
1147 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_close()
1152 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_close()
1154 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_close()
1156 if(cf->next) in cf_h2_proxy_close()
1157 cf->next->cft->do_close(cf->next, data); in cf_h2_proxy_close()
1160 static void cf_h2_proxy_destroy(struct Curl_cfilter *cf, in cf_h2_proxy_destroy() argument
1163 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_destroy()
1168 cf->ctx = NULL; in cf_h2_proxy_destroy()
1172 static CURLcode cf_h2_proxy_shutdown(struct Curl_cfilter *cf, in cf_h2_proxy_shutdown() argument
1175 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_shutdown()
1180 if(!cf->connected || !ctx->h2 || cf->shutdown || ctx->conn_closed) { in cf_h2_proxy_shutdown()
1185 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_shutdown()
1203 result = proxy_h2_progress_egress(cf, data); in cf_h2_proxy_shutdown()
1205 result = proxy_h2_progress_ingress(cf, data); in cf_h2_proxy_shutdown()
1211 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_shutdown()
1212 cf->shutdown = (result || *done); in cf_h2_proxy_shutdown()
1216 static bool cf_h2_proxy_data_pending(struct Curl_cfilter *cf, in cf_h2_proxy_data_pending() argument
1219 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_data_pending()
1224 return cf->next ? cf->next->cft->has_data_pending(cf->next, data) : FALSE; in cf_h2_proxy_data_pending()
1227 static void cf_h2_proxy_adjust_pollset(struct Curl_cfilter *cf, in cf_h2_proxy_adjust_pollset() argument
1231 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_adjust_pollset()
1233 curl_socket_t sock = Curl_conn_cf_get_socket(cf, data); in cf_h2_proxy_adjust_pollset()
1236 if(!cf->connected && ctx->h2) { in cf_h2_proxy_adjust_pollset()
1248 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_adjust_pollset()
1260 CURL_TRC_CF(data, cf, "adjust_pollset, want_recv=%d want_send=%d", in cf_h2_proxy_adjust_pollset()
1262 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_adjust_pollset()
1264 else if(ctx->sent_goaway && !cf->shutdown) { in cf_h2_proxy_adjust_pollset()
1266 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_adjust_pollset()
1272 CURL_TRC_CF(data, cf, "adjust_pollset, want_recv=%d want_send=%d", in cf_h2_proxy_adjust_pollset()
1274 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_adjust_pollset()
1278 static ssize_t h2_handle_tunnel_close(struct Curl_cfilter *cf, in h2_handle_tunnel_close() argument
1282 struct cf_h2_proxy_ctx *ctx = cf->ctx; in h2_handle_tunnel_close()
1286 CURL_TRC_CF(data, cf, "[%d] REFUSED_STREAM, try again on a new " in h2_handle_tunnel_close()
1288 connclose(cf->conn, "REFUSED_STREAM"); /* do not use this anymore */ in h2_handle_tunnel_close()
1307 CURL_TRC_CF(data, cf, "[%d] handle_tunnel_close -> %zd, %d", in h2_handle_tunnel_close()
1312 static ssize_t tunnel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, in tunnel_recv() argument
1315 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_recv()
1329 nread = h2_handle_tunnel_close(cf, data, err); in tunnel_recv()
1345 CURL_TRC_CF(data, cf, "[%d] tunnel_recv(len=%zu) -> %zd, %d", in tunnel_recv()
1350 static ssize_t cf_h2_proxy_recv(struct Curl_cfilter *cf, in cf_h2_proxy_recv() argument
1354 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_recv()
1363 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_recv()
1366 *err = proxy_h2_progress_ingress(cf, data); in cf_h2_proxy_recv()
1371 nread = tunnel_recv(cf, data, buf, len, err); in cf_h2_proxy_recv()
1374 CURL_TRC_CF(data, cf, "[%d] increase window by %zd", in cf_h2_proxy_recv()
1379 result = proxy_h2_progress_egress(cf, data); in cf_h2_proxy_recv()
1390 drain_tunnel(cf, data, &ctx->tunnel); in cf_h2_proxy_recv()
1392 CURL_TRC_CF(data, cf, "[%d] cf_recv(len=%zu) -> %zd %d", in cf_h2_proxy_recv()
1394 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_recv()
1398 static ssize_t cf_h2_proxy_send(struct Curl_cfilter *cf, in cf_h2_proxy_send() argument
1403 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_send()
1414 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_send()
1437 result = proxy_h2_progress_ingress(cf, data); in cf_h2_proxy_send()
1446 result = proxy_h2_progress_egress(cf, data); in cf_h2_proxy_send()
1461 CURL_TRC_CF(data, cf, "[0] send: nothing to do in this session"); in cf_h2_proxy_send()
1472 drain_tunnel(cf, data, &ctx->tunnel); in cf_h2_proxy_send()
1474 CURL_TRC_CF(data, cf, "[%d] cf_send(len=%zu) -> %zd, %d, " in cf_h2_proxy_send()
1482 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_send()
1486 static CURLcode cf_h2_proxy_flush(struct Curl_cfilter *cf, in cf_h2_proxy_flush() argument
1489 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_flush()
1493 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_flush()
1503 result = proxy_h2_progress_egress(cf, data); in cf_h2_proxy_flush()
1506 CURL_TRC_CF(data, cf, "[%d] flush -> %d, " in cf_h2_proxy_flush()
1514 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_flush()
1518 static bool proxy_h2_connisalive(struct Curl_cfilter *cf, in proxy_h2_connisalive() argument
1522 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_connisalive()
1526 if(!cf->next || !cf->next->cft->is_alive(cf->next, data, input_pending)) in proxy_h2_connisalive()
1537 nread = Curl_bufq_slurp(&ctx->inbufq, proxy_nw_in_reader, cf, &result); in proxy_h2_connisalive()
1539 if(proxy_h2_process_pending_input(cf, data, &result) < 0) in proxy_h2_connisalive()
1555 static bool cf_h2_proxy_is_alive(struct Curl_cfilter *cf, in cf_h2_proxy_is_alive() argument
1559 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_is_alive()
1563 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_is_alive()
1564 result = (ctx && ctx->h2 && proxy_h2_connisalive(cf, data, input_pending)); in cf_h2_proxy_is_alive()
1565 CURL_TRC_CF(data, cf, "[0] conn alive -> %d, input_pending=%d", in cf_h2_proxy_is_alive()
1567 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_is_alive()
1571 static CURLcode cf_h2_proxy_query(struct Curl_cfilter *cf, in cf_h2_proxy_query() argument
1575 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_query()
1581 CURL_TRC_CF(data, cf, "needs flush"); in cf_h2_proxy_query()
1590 return cf->next ? in cf_h2_proxy_query()
1591 cf->next->cft->query(cf->next, data, query, pres1, pres2) : in cf_h2_proxy_query()
1595 static CURLcode cf_h2_proxy_cntrl(struct Curl_cfilter *cf, in cf_h2_proxy_cntrl() argument
1607 CF_DATA_SAVE(save, cf, data); in cf_h2_proxy_cntrl()
1608 result = cf_h2_proxy_flush(cf, data); in cf_h2_proxy_cntrl()
1609 CF_DATA_RESTORE(cf, save); in cf_h2_proxy_cntrl()
1636 CURLcode Curl_cf_h2_proxy_insert_after(struct Curl_cfilter *cf, in Curl_cf_h2_proxy_insert_after() argument
1652 Curl_conn_cf_insert_after(cf, cf_h2_proxy); in Curl_cf_h2_proxy_insert_after()