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