1 /* httpd_h2.h -HTTP/2 support functions
2  *
3  * Copyright (c) 1994-2018 Carnegie Mellon University.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * 3. The name "Carnegie Mellon University" must not be used to
18  *    endorse or promote products derived from this software without
19  *    prior written permission. For permission or any legal
20  *    details, please contact
21  *      Carnegie Mellon University
22  *      Center for Technology Transfer and Enterprise Creation
23  *      4615 Forbes Avenue
24  *      Suite 302
25  *      Pittsburgh, PA  15213
26  *      (412) 268-7393, fax: (412) 268-7395
27  *      innovation@andrew.cmu.edu
28  *
29  * 4. Redistributions of any form whatsoever must retain the following
30  *    acknowledgment:
31  *    "This product includes software developed by Computing Services
32  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
33  *
34  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41  *
42  */
43 
44 #ifndef HTTPD_H2_H
45 #define HTTPD_H2_H
46 
47 #include <config.h>
48 
49 #ifdef HAVE_NGHTTP2
50 #include <nghttp2/nghttp2.h>
51 
52 #else /* !HAVE_NGHTTP2 */
53 
54 #define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID ""
55 
56 #endif /* HAVE_NGHTTP2 */
57 
58 #ifndef HAVE_SSL
59 #define SSL void
60 #endif
61 
62 #include "md5.h"
63 
64 extern int (*alpn_select_cb)(SSL *ssl,
65                              const unsigned char **out, unsigned char *outlen,
66                              const unsigned char *in, unsigned int inlen,
67                              void *arg);
68 
69 extern void http2_init(struct buf *serverinfo);
70 
71 extern int http2_enabled();
72 
73 extern void http2_done();
74 
75 extern int http2_preface(struct http_connection *conn);
76 
77 extern int http2_start_session(struct transaction_t *txn,
78                                struct http_connection *conn);
79 
80 extern void http2_end_session(void *http2_ctx);
81 
82 extern void http2_output(struct transaction_t *txn);
83 
84 extern void http2_input(struct transaction_t *txn);
85 
86 extern void http2_begin_headers(struct transaction_t *txn);
87 
88 extern void http2_add_header(struct transaction_t *txn,
89                              const char *name, struct buf *value);
90 
91 extern int http2_end_headers(struct transaction_t *txn, long code);
92 
93 extern int http2_data_chunk(struct transaction_t *txn,
94                             const char *data, unsigned datalen,
95                             int last_chunk, MD5_CTX *md5ctx);
96 
97 extern int32_t http2_get_streamid(void *http2_strm);
98 
99 extern void http2_end_stream(void *http2_strm);
100 
101 #endif /* HTTPD_H2_H */
102