2
0

altsvc.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
  26. #include <curl/curl.h>
  27. #include "llist.h"
  28. enum alpnid {
  29. ALPN_none,
  30. ALPN_h1,
  31. ALPN_h2,
  32. ALPN_h2c,
  33. ALPN_h3
  34. };
  35. struct altsvc {
  36. char *srchost;
  37. char *dsthost;
  38. unsigned short srcport;
  39. unsigned short dstport;
  40. enum alpnid srcalpnid;
  41. enum alpnid dstalpnid;
  42. time_t expires;
  43. bool persist;
  44. int prio;
  45. struct curl_llist_element node;
  46. };
  47. struct altsvcinfo {
  48. char *filename;
  49. struct curl_llist list; /* list of entries */
  50. size_t num; /* number of alt-svc entries */
  51. long flags; /* the publicly set bitmask */
  52. };
  53. const char *Curl_alpnid2str(enum alpnid id);
  54. struct altsvcinfo *Curl_altsvc_init(void);
  55. CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
  56. CURLcode Curl_altsvc_save(struct altsvcinfo *asi, const char *file);
  57. CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
  58. void Curl_altsvc_cleanup(struct altsvcinfo *altsvc);
  59. CURLcode Curl_altsvc_parse(struct Curl_easy *data,
  60. struct altsvcinfo *altsvc, const char *value,
  61. enum alpnid srcalpn, const char *srchost,
  62. unsigned short srcport);
  63. bool Curl_altsvc_lookup(struct altsvcinfo *asi,
  64. enum alpnid srcalpnid, const char *srchost,
  65. int srcport,
  66. enum alpnid *dstalpnid, const char **dsthost,
  67. int *dstport);
  68. #else
  69. /* disabled */
  70. #define Curl_altsvc_save(a,b)
  71. #endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
  72. #endif /* HEADER_CURL_ALTSVC_H */