1#ifndef HEADER_CURL_ALTSVC_H
2#define HEADER_CURL_ALTSVC_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 2019 - 2022, Daniel Stenberg, <[email protected]>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
27
28#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
29#include <curl/curl.h>
30#include "llist.h"
31
32enum alpnid {
33 ALPN_none = 0,
34 ALPN_h1 = CURLALTSVC_H1,
35 ALPN_h2 = CURLALTSVC_H2,
36 ALPN_h3 = CURLALTSVC_H3
37};
38
39struct althost {
40 char *host;
41 unsigned short port;
42 enum alpnid alpnid;
43};
44
45struct altsvc {
46 struct althost src;
47 struct althost dst;
48 time_t expires;
49 bool persist;
50 int prio;
51 struct Curl_llist_element node;
52};
53
54struct altsvcinfo {
55 char *filename;
56 struct Curl_llist list; /* list of entries */
57 long flags; /* the publicly set bitmask */
58};
59
60const char *Curl_alpnid2str(enum alpnid id);
61struct altsvcinfo *Curl_altsvc_init(void);
62CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
63CURLcode Curl_altsvc_save(struct Curl_easy *data,
64 struct altsvcinfo *asi, const char *file);
65CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
66void Curl_altsvc_cleanup(struct altsvcinfo **altsvc);
67CURLcode Curl_altsvc_parse(struct Curl_easy *data,
68 struct altsvcinfo *altsvc, const char *value,
69 enum alpnid srcalpn, const char *srchost,
70 unsigned short srcport);
71bool Curl_altsvc_lookup(struct altsvcinfo *asi,
72 enum alpnid srcalpnid, const char *srchost,
73 int srcport,
74 struct altsvc **dstentry,
75 const int versions); /* CURLALTSVC_H* bits */
76#else
77/* disabled */
78#define Curl_altsvc_save(a,b,c)
79#define Curl_altsvc_cleanup(x)
80#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
81#endif /* HEADER_CURL_ALTSVC_H */
82