altsvc.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, <[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. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
  28. #include <curl/curl.h>
  29. #include "llist.h"
  30. struct althost {
  31. char *host;
  32. unsigned short port;
  33. enum alpnid alpnid;
  34. };
  35. struct altsvc {
  36. struct althost src;
  37. struct althost dst;
  38. time_t expires;
  39. struct Curl_llist_node node;
  40. unsigned int prio;
  41. BIT(persist);
  42. };
  43. struct altsvcinfo {
  44. char *filename;
  45. struct Curl_llist list; /* list of entries */
  46. long flags; /* the publicly set bitmask */
  47. };
  48. const char *Curl_alpnid2str(enum alpnid id);
  49. struct altsvcinfo *Curl_altsvc_init(void);
  50. CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
  51. CURLcode Curl_altsvc_save(struct Curl_easy *data,
  52. struct altsvcinfo *asi, const char *file);
  53. CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
  54. void Curl_altsvc_cleanup(struct altsvcinfo **altsvc);
  55. CURLcode Curl_altsvc_parse(struct Curl_easy *data,
  56. struct altsvcinfo *altsvc, const char *value,
  57. enum alpnid srcalpn, const char *srchost,
  58. unsigned short srcport);
  59. bool Curl_altsvc_lookup(struct altsvcinfo *asi,
  60. enum alpnid srcalpnid, const char *srchost,
  61. int srcport,
  62. struct altsvc **dstentry,
  63. const int versions); /* CURLALTSVC_H* bits */
  64. #else
  65. /* disabled */
  66. #define Curl_altsvc_save(a,b,c)
  67. #define Curl_altsvc_cleanup(x)
  68. #endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
  69. #endif /* HEADER_CURL_ALTSVC_H */