VirtualBox

source: vbox/trunk/src/libs/curl-8.0.1/lib/cf-socket.h@ 99459

Last change on this file since 99459 was 99459, checked in by vboxsync, 20 months ago

setting missed svn:sync-process property on curl-8.0.1 files

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

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