2
0

altsvc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef HEADER_CURL_ALTSVC_H
  2. #define HEADER_CURL_ALTSVC_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 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.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. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
  28. #include <curl/curl.h>
  29. #include "llist.h"
  30. enum alpnid {
  31. ALPN_none = 0,
  32. ALPN_h1 = CURLALTSVC_H1,
  33. ALPN_h2 = CURLALTSVC_H2,
  34. ALPN_h3 = CURLALTSVC_H3
  35. };
  36. struct althost {
  37. char *host;
  38. unsigned short port;
  39. enum alpnid alpnid;
  40. };
  41. struct altsvc {
  42. struct althost src;
  43. struct althost dst;
  44. time_t expires;
  45. bool persist;
  46. int prio;
  47. struct Curl_llist_element node;
  48. };
  49. struct altsvcinfo {
  50. char *filename;
  51. struct Curl_llist list; /* list of entries */
  52. long flags; /* the publicly set bitmask */
  53. };
  54. const char *Curl_alpnid2str(enum alpnid id);
  55. struct altsvcinfo *Curl_altsvc_init(void);
  56. CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
  57. CURLcode Curl_altsvc_save(struct Curl_easy *data,
  58. struct altsvcinfo *asi, const char *file);
  59. CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
  60. void Curl_altsvc_cleanup(struct altsvcinfo **altsvc);
  61. CURLcode Curl_altsvc_parse(struct Curl_easy *data,
  62. struct altsvcinfo *altsvc, const char *value,
  63. enum alpnid srcalpn, const char *srchost,
  64. unsigned short srcport);
  65. bool Curl_altsvc_lookup(struct altsvcinfo *asi,
  66. enum alpnid srcalpnid, const char *srchost,
  67. int srcport,
  68. struct altsvc **dstentry,
  69. const int versions); /* CURLALTSVC_H* bits */
  70. #else
  71. /* disabled */
  72. #define Curl_altsvc_save(a,b,c)
  73. #define Curl_altsvc_cleanup(x)
  74. #endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
  75. #endif /* HEADER_CURL_ALTSVC_H */