VirtualBox

source: vbox/trunk/src/libs/curl-8.7.1/lib/doh.h@ 106165

最後變更 在這個檔案從106165是 104083,由 vboxsync 提交於 8 月 前

curl-8.7.1: Applied and adjusted our curl changes to 8.4.0. bugref:10639

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.6 KB
 
1#ifndef HEADER_CURL_DOH_H
2#define HEADER_CURL_DOH_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
27#include "urldata.h"
28#include "curl_addrinfo.h"
29
30#ifndef CURL_DISABLE_DOH
31
32typedef enum {
33 DOH_OK,
34 DOH_DNS_BAD_LABEL, /* 1 */
35 DOH_DNS_OUT_OF_RANGE, /* 2 */
36 DOH_DNS_LABEL_LOOP, /* 3 */
37 DOH_TOO_SMALL_BUFFER, /* 4 */
38 DOH_OUT_OF_MEM, /* 5 */
39 DOH_DNS_RDATA_LEN, /* 6 */
40 DOH_DNS_MALFORMAT, /* 7 */
41 DOH_DNS_BAD_RCODE, /* 8 - no such name */
42 DOH_DNS_UNEXPECTED_TYPE, /* 9 */
43 DOH_DNS_UNEXPECTED_CLASS, /* 10 */
44 DOH_NO_CONTENT, /* 11 */
45 DOH_DNS_BAD_ID, /* 12 */
46 DOH_DNS_NAME_TOO_LONG /* 13 */
47} DOHcode;
48
49typedef enum {
50 DNS_TYPE_A = 1,
51 DNS_TYPE_NS = 2,
52 DNS_TYPE_CNAME = 5,
53 DNS_TYPE_AAAA = 28,
54 DNS_TYPE_DNAME = 39 /* RFC6672 */
55} DNStype;
56
57/* one of these for each DoH request */
58struct dnsprobe {
59 CURL *easy;
60 DNStype dnstype;
61 unsigned char dohbuffer[512];
62 size_t dohlen;
63 struct dynbuf serverdoh;
64};
65
66struct dohdata {
67 struct curl_slist *headers;
68 struct dnsprobe probe[DOH_PROBE_SLOTS];
69 unsigned int pending; /* still outstanding requests */
70 int port;
71 const char *host;
72};
73
74/*
75 * Curl_doh() resolve a name using DoH (DNS-over-HTTPS). It resolves a name
76 * and returns a 'Curl_addrinfo *' with the address information.
77 */
78
79struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
80 const char *hostname,
81 int port,
82 int *waitp);
83
84CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
85 struct Curl_dns_entry **dns);
86
87int Curl_doh_getsock(struct connectdata *conn, curl_socket_t *socks);
88
89#define DOH_MAX_ADDR 24
90#define DOH_MAX_CNAME 4
91
92struct dohaddr {
93 int type;
94 union {
95 unsigned char v4[4]; /* network byte order */
96 unsigned char v6[16];
97 } ip;
98};
99
100struct dohentry {
101 struct dynbuf cname[DOH_MAX_CNAME];
102 struct dohaddr addr[DOH_MAX_ADDR];
103 int numaddr;
104 unsigned int ttl;
105 int numcname;
106};
107
108
109#ifdef DEBUGBUILD
110DOHcode doh_encode(const char *host,
111 DNStype dnstype,
112 unsigned char *dnsp, /* buffer */
113 size_t len, /* buffer size */
114 size_t *olen); /* output length */
115DOHcode doh_decode(const unsigned char *doh,
116 size_t dohlen,
117 DNStype dnstype,
118 struct dohentry *d);
119void de_init(struct dohentry *d);
120void de_cleanup(struct dohentry *d);
121#endif
122
123extern struct curl_trc_feat Curl_doh_trc;
124
125#else /* if DoH is disabled */
126#define Curl_doh(a,b,c,d) NULL
127#define Curl_doh_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
128#endif
129
130#endif /* HEADER_CURL_DOH_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette