• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef HEADER_CURL_ALTSVC_H
2 #define HEADER_CURL_ALTSVC_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, 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.haxx.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  ***************************************************************************/
24 #include "curl_setup.h"
25 
26 #if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
27 #include <curl/curl.h>
28 #include "llist.h"
29 
30 enum alpnid {
31   ALPN_none,
32   ALPN_h1,
33   ALPN_h2,
34   ALPN_h2c,
35   ALPN_h3
36 };
37 
38 struct altsvc {
39   char *srchost;
40   char *dsthost;
41   unsigned short srcport;
42   unsigned short dstport;
43   enum alpnid srcalpnid;
44   enum alpnid dstalpnid;
45   time_t expires;
46   bool persist;
47   int prio;
48   struct curl_llist_element node;
49 };
50 
51 struct altsvcinfo {
52   char *filename;
53   struct curl_llist list; /* list of entries */
54   size_t num; /* number of alt-svc entries */
55   long flags; /* the publicly set bitmask */
56 };
57 
58 const char *Curl_alpnid2str(enum alpnid id);
59 struct altsvcinfo *Curl_altsvc_init(void);
60 CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
61 CURLcode Curl_altsvc_save(struct altsvcinfo *asi, const char *file);
62 CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
63 void Curl_altsvc_cleanup(struct altsvcinfo *altsvc);
64 CURLcode Curl_altsvc_parse(struct Curl_easy *data,
65                            struct altsvcinfo *altsvc, const char *value,
66                            enum alpnid srcalpn, const char *srchost,
67                            unsigned short srcport);
68 bool Curl_altsvc_lookup(struct altsvcinfo *asi,
69                         enum alpnid srcalpnid, const char *srchost,
70                         int srcport,
71                         enum alpnid *dstalpnid, const char **dsthost,
72                         int *dstport);
73 #else
74 /* disabled */
75 #define Curl_altsvc_save(a,b)
76 #endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
77 #endif /* HEADER_CURL_ALTSVC_H */
78