#include <stddef.h>
#include <stdbool.h>
#include <time.h>
Go to the source code of this file.
Shared functions that are private to Connections
- Authors
-
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file private.h.
◆ raw_socket_close()
◆ raw_socket_open()
Open a socket - Implements Connection::open()
Definition at line 116 of file raw.c.
120 char *host_idna = NULL;
122 #ifdef HAVE_GETADDRINFO
127 struct addrinfo hints;
128 struct addrinfo *res = NULL;
129 struct addrinfo *cur = NULL;
132 memset(&hints, 0,
sizeof(hints));
135 hints.ai_family = AF_UNSPEC;
137 hints.ai_family = AF_INET;
139 hints.ai_socktype = SOCK_STREAM;
141 snprintf(port,
sizeof(port),
"%d", conn->
account.
port);
156 rc = getaddrinfo(host_idna, port, &hints, &res);
172 for (cur = res; cur; cur = cur->ai_next)
174 int fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
180 fcntl(fd, F_SETFD, FD_CLOEXEC);
193 struct sockaddr_in sin;
194 struct hostent *he = NULL;
196 memset(&sin, 0,
sizeof(sin));
198 sin.sin_family = AF_INET;
213 he = gethostbyname(host_idna);
230 for (
int i = 0; he->h_addr_list[i]; i++)
232 memcpy(&sin.sin_addr, he->h_addr_list[i], he->h_length);
233 int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
240 fcntl(fd, F_SETFD, FD_CLOEXEC);
252 (rc > 0) ? strerror(rc) :
_(
"unknown error"));
◆ raw_socket_poll()
int raw_socket_poll |
( |
struct Connection * |
conn, |
|
|
time_t |
wait_secs |
|
) |
| |
Checks whether reads would block - Implements Connection::poll()
Definition at line 322 of file raw.c.
330 uint64_t wait_millis = wait_secs * 1000UL;
334 tv.tv_sec = wait_millis / 1000;
335 tv.tv_usec = (wait_millis % 1000) * 1000;
338 FD_SET(conn->
fd, &rfds);
341 const int rc = select(conn->
fd + 1, &rfds, NULL, NULL, &tv);
344 if ((rc > 0) || ((rc < 0) && (errno != EINTR)))
350 wait_millis += pre_t;
351 if (wait_millis <= post_t)
353 wait_millis -= post_t;
◆ raw_socket_read()
int raw_socket_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
Read data from a socket - Implements Connection::read()
Definition at line 262 of file raw.c.
269 rc = read(conn->
fd, buf, count);
270 }
while (rc < 0 && (errno == EINTR));
◆ raw_socket_write()
int raw_socket_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
Write data to a socket - Implements Connection::write()
Definition at line 292 of file raw.c.
302 rc = write(conn->
fd, buf + sent, count - sent);
303 }
while (rc < 0 && (errno == EINTR));
313 }
while ((sent < count) && (
SigInt == 0));
◆ mutt_tunnel_socket_setup()
void mutt_tunnel_socket_setup |
( |
struct Connection * |
conn | ) |
|
sets up tunnel connection functions
- Parameters
-
Assign tunnel socket functions to the Connection conn.
Definition at line 233 of file tunnel.c.
◆ C_CertificateFile
const char* C_CertificateFile |
Config: (ssl) File containing trusted certificates.
Definition at line 42 of file config.c.
◆ C_ConnectTimeout
Config: Timeout for making network connections (-1 to wait indefinitely)
Definition at line 37 of file config.c.
◆ C_EntropyFile
const char* C_EntropyFile |
Config: (ssl) File/device containing random data to initialise SSL.
Definition at line 43 of file config.c.
◆ C_Preconnect
Config: External command to run prior to opening a socket.
Definition at line 38 of file config.c.
◆ C_SslCaCertificatesFile
const char* C_SslCaCertificatesFile |
Config: File containing trusted CA certificates.
Definition at line 64 of file config.c.
◆ C_SslCiphers
Config: (ssl) Ciphers to use when using SSL.
Definition at line 44 of file config.c.
◆ C_SslClientCert
const char* C_SslClientCert |
Config: (ssl) File containing client certificates.
Definition at line 45 of file config.c.
◆ C_SslMinDhPrimeBits
short C_SslMinDhPrimeBits |
Config: Minimum keysize for Diffie-Hellman key exchange.
Definition at line 65 of file config.c.
◆ C_SslUseSslv2
◆ C_SslUseSslv3
Config: (ssl) INSECURE: Use SSLv3 for authentication.
Definition at line 52 of file config.c.
◆ C_SslUseTlsv11
Config: (ssl) Use TLSv1.1 for authentication.
Definition at line 54 of file config.c.
◆ C_SslUseTlsv12
Config: (ssl) Use TLSv1.2 for authentication.
Definition at line 55 of file config.c.
◆ C_SslUseTlsv13
Config: (ssl) Use TLSv1.3 for authentication.
Definition at line 56 of file config.c.
◆ C_SslUseTlsv1
Config: (ssl) Use TLSv1 for authentication.
Definition at line 53 of file config.c.
◆ C_SslUseSystemCerts
◆ C_SslVerifyDates
Config: (ssl) Verify the dates on the server certificate.
Definition at line 57 of file config.c.
◆ C_SslVerifyHost
Config: (ssl) Verify the server's hostname against the certificate.
Definition at line 58 of file config.c.
◆ C_SslVerifyPartialChains
bool C_SslVerifyPartialChains |
Config: (ssl) Allow verification using partial certificate chains.
Definition at line 60 of file config.c.
◆ C_TunnelIsSecure
Config: Assume a tunneled connection is secure.
Definition at line 40 of file config.c.
◆ C_UseIpv6
Config: Lookup IPv6 addresses when making connections.
Definition at line 68 of file config.c.
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
char host[128]
Server to login to.
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
int mutt_idna_to_ascii_lz(const char *input, char **output, uint8_t flags)
struct ConnAccount account
Account details: username, password, etc.
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
static int socket_connect(int fd, struct sockaddr *sa)
set up to connect to a socket fd
int fd
Socket file descriptor.
int(* close)(struct Connection *conn)
Close a socket Connection.
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
int(* open)(struct Connection *conn)
Note about ssf: in actuality, NeoMutt uses this as a boolean to determine if the connection is "secur...
static int tunnel_socket_write(struct Connection *conn, const char *buf, size_t count)
Write data to a tunnel socket - Implements Connection::write()
bool C_TunnelIsSecure
Config: Assume a tunneled connection is secure.
static int tunnel_socket_close(struct Connection *conn)
Close a tunnel socket - Implements Connection::close()
int(* write)(struct Connection *conn, const char *buf, size_t count)
Write to a socket Connection.
static int tunnel_socket_open(struct Connection *conn)
Open a tunnel socket - Implements Connection::open()
static int tunnel_socket_read(struct Connection *conn, char *buf, size_t count)
Read data from a tunnel socket - Implements Connection::read()
unsigned short port
Port to connect to.
void mutt_query_exit(void)
Ask the user if they want to leave NeoMutt.
bool C_UseIpv6
Config: Lookup IPv6 addresses when making connections.
int(* poll)(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block.
#define mutt_message(...)
void(* close)(void **cctx)
Close a compression context.
unsigned int ssf
Security strength factor, in bits (see below)
int(* read)(struct Connection *conn, char *buf, size_t count)
Read from a socket Connection.
static int tunnel_socket_poll(struct Connection *conn, time_t wait_secs)
Checks whether tunnel reads would block - Implements Connection::poll()