1 /*- 2 * Copyright (c) 2016 Varnish Software AS 3 * All rights reserved. 4 * 5 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk> 6 * 7 * SPDX-License-Identifier: BSD-2-Clause 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * A transport is how we talk HTTP for a given request. 31 * 32 * This is different from a protocol because ESI child requests have 33 * their own "protocol" to talk to the parent ESI request, which may 34 * or may not, be talking a "real" HTTP protocol itself. 35 * 36 */ 37 38 struct req; 39 struct boc; 40 41 typedef void vtr_deliver_f (struct req *, struct boc *, int sendbody); 42 typedef void vtr_req_body_f (struct req *); 43 typedef void vtr_sess_panic_f (struct vsb *, const struct sess *); 44 typedef void vtr_req_panic_f (struct vsb *, const struct req *); 45 typedef void vtr_req_fail_f (struct req *, enum sess_close); 46 typedef void vtr_reembark_f (struct worker *, struct req *); 47 typedef int vtr_minimal_response_f (struct req *, uint16_t status); 48 49 struct transport { 50 unsigned magic; 51 #define TRANSPORT_MAGIC 0xf157f32f 52 53 uint16_t number; 54 55 const char *proto_ident; // for -a args 56 const char *name; 57 58 task_func_t *new_session; 59 task_func_t *unwait; 60 61 vtr_req_fail_f *req_fail; 62 vtr_req_body_f *req_body; 63 vtr_deliver_f *deliver; 64 vtr_sess_panic_f *sess_panic; 65 vtr_req_panic_f *req_panic; 66 vtr_reembark_f *reembark; 67 vtr_minimal_response_f *minimal_response; 68 69 VTAILQ_ENTRY(transport) list; 70 }; 71 72 extern struct transport PROXY_transport; 73 extern struct transport HTTP1_transport; 74 extern struct transport H2_transport; 75 htc_complete_f H2_prism_complete; 76 void H2_PU_Sess(struct worker *, struct sess *, struct req *); 77 void H2_OU_Sess(struct worker *, struct sess *, struct req *); 78 79 const struct transport *XPORT_ByNumber(uint16_t no); 80 int VPX_Send_Proxy(int fd, int version, const struct sess *); 81 82 /* cache_session.c */ 83 struct sess *SES_New(struct pool *); 84 void SES_Delete(struct sess *, enum sess_close reason, vtim_real now); 85 void SES_DeleteHS(struct sess *, enum htc_status_e hs, vtim_real now); 86 void SES_Close(struct sess *, enum sess_close reason); 87 void SES_SetTransport(struct worker *, struct sess *, struct req *, 88 const struct transport *); 89