VirtualBox

source: vbox/trunk/src/libs/curl-8.7.1/lib/cf-socket.h@ 106542

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

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

檔案大小: 6.1 KB
 
1#ifndef HEADER_CURL_CF_SOCKET_H
2#define HEADER_CURL_CF_SOCKET_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
28#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
29#include "sockaddr.h"
30
31struct Curl_addrinfo;
32struct Curl_cfilter;
33struct Curl_easy;
34struct connectdata;
35struct Curl_sockaddr_ex;
36struct ip_quadruple;
37
38/*
39 * The Curl_sockaddr_ex structure is basically libcurl's external API
40 * curl_sockaddr structure with enough space available to directly hold any
41 * protocol-specific address structures. The variable declared here will be
42 * used to pass / receive data to/from the fopensocket callback if this has
43 * been set, before that, it is initialized from parameters.
44 */
45struct Curl_sockaddr_ex {
46 int family;
47 int socktype;
48 int protocol;
49 unsigned int addrlen;
50 union {
51 struct sockaddr addr;
52 struct Curl_sockaddr_storage buff;
53 } _sa_ex_u;
54};
55#define sa_addr _sa_ex_u.addr
56
57
58/*
59 * Create a socket based on info from 'conn' and 'ai'.
60 *
61 * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open
62 * socket callback is set, used that!
63 *
64 */
65CURLcode Curl_socket_open(struct Curl_easy *data,
66 const struct Curl_addrinfo *ai,
67 struct Curl_sockaddr_ex *addr,
68 int transport,
69 curl_socket_t *sockfd);
70
71int Curl_socket_close(struct Curl_easy *data, struct connectdata *conn,
72 curl_socket_t sock);
73
74#ifdef USE_WINSOCK
75/* When you run a program that uses the Windows Sockets API, you may
76 experience slow performance when you copy data to a TCP server.
77
78 https://support.microsoft.com/kb/823764
79
80 Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
81 Buffer Size
82
83*/
84void Curl_sndbufset(curl_socket_t sockfd);
85#else
86#define Curl_sndbufset(y) Curl_nop_stmt
87#endif
88
89/**
90 * Assign the address `ai` to the Curl_sockaddr_ex `dest` and
91 * set the transport used.
92 */
93void Curl_sock_assign_addr(struct Curl_sockaddr_ex *dest,
94 const struct Curl_addrinfo *ai,
95 int transport);
96
97/**
98 * Creates a cfilter that opens a TCP socket to the given address
99 * when calling its `connect` implementation.
100 * The filter will not touch any connection/data flags and can be
101 * used in happy eyeballing. Once selected for use, its `_active()`
102 * method needs to be called.
103 */
104CURLcode Curl_cf_tcp_create(struct Curl_cfilter **pcf,
105 struct Curl_easy *data,
106 struct connectdata *conn,
107 const struct Curl_addrinfo *ai,
108 int transport);
109
110/**
111 * Creates a cfilter that opens a UDP socket to the given address
112 * when calling its `connect` implementation.
113 * The filter will not touch any connection/data flags and can be
114 * used in happy eyeballing. Once selected for use, its `_active()`
115 * method needs to be called.
116 */
117CURLcode Curl_cf_udp_create(struct Curl_cfilter **pcf,
118 struct Curl_easy *data,
119 struct connectdata *conn,
120 const struct Curl_addrinfo *ai,
121 int transport);
122
123/**
124 * Creates a cfilter that opens a UNIX socket to the given address
125 * when calling its `connect` implementation.
126 * The filter will not touch any connection/data flags and can be
127 * used in happy eyeballing. Once selected for use, its `_active()`
128 * method needs to be called.
129 */
130CURLcode Curl_cf_unix_create(struct Curl_cfilter **pcf,
131 struct Curl_easy *data,
132 struct connectdata *conn,
133 const struct Curl_addrinfo *ai,
134 int transport);
135
136/**
137 * Creates a cfilter that keeps a listening socket.
138 */
139CURLcode Curl_conn_tcp_listen_set(struct Curl_easy *data,
140 struct connectdata *conn,
141 int sockindex,
142 curl_socket_t *s);
143
144/**
145 * Replace the listen socket with the accept()ed one.
146 */
147CURLcode Curl_conn_tcp_accepted_set(struct Curl_easy *data,
148 struct connectdata *conn,
149 int sockindex,
150 curl_socket_t *s);
151
152/**
153 * Peek at the socket and remote ip/port the socket filter is using.
154 * The filter owns all returned values.
155 * @param psock pointer to hold socket descriptor or NULL
156 * @param paddr pointer to hold addr reference or NULL
157 * @param pip pointer to get IP quadruple or NULL
158 * Returns error if the filter is of invalid type.
159 */
160CURLcode Curl_cf_socket_peek(struct Curl_cfilter *cf,
161 struct Curl_easy *data,
162 curl_socket_t *psock,
163 const struct Curl_sockaddr_ex **paddr,
164 struct ip_quadruple *pip);
165
166extern struct Curl_cftype Curl_cft_tcp;
167extern struct Curl_cftype Curl_cft_udp;
168extern struct Curl_cftype Curl_cft_unix;
169extern struct Curl_cftype Curl_cft_tcp_accept;
170
171#endif /* HEADER_CURL_CF_SOCKET_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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