NeoMutt  2023-03-22
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference

Connection Library. More...

#include "config.h"
#include "connaccount.h"
#include "connection.h"
#include "sasl_plain.h"
#include "socket.h"
#include "zstrm.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mutt_ssl_starttls (struct Connection *conn)
 Negotiate TLS over an already opened connection. More...
 
int getdnsdomainname (struct Buffer *result)
 Lookup the host's name using DNS. More...
 

Detailed Description

Connection Library.

Authors
  • Richard Russon

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 lib.h.

Function Documentation

◆ mutt_ssl_starttls()

int mutt_ssl_starttls ( struct Connection conn)

Negotiate TLS over an already opened connection.

Parameters
connConnection to a server
Return values
0Success
-1Error

Definition at line 1143 of file gnutls.c.

1144{
1145 if (tls_init() < 0)
1146 return -1;
1147
1148 if (tls_negotiate(conn) < 0)
1149 return -1;
1150
1151 conn->read = tls_socket_read;
1152 conn->write = tls_socket_write;
1153 conn->close = tls_starttls_close;
1154 conn->poll = tls_socket_poll;
1155
1156 return 0;
1157}
static int tls_init(void)
Set up Gnu TLS.
Definition: gnutls.c:91
static int tls_negotiate(struct Connection *conn)
Negotiate TLS connection.
Definition: gnutls.c:870
static int tls_starttls_close(struct Connection *conn)
Close a TLS connection - Implements Connection::close() -.
Definition: gnutls.c:1104
static int tls_socket_poll(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block - Implements Connection::poll() -.
Definition: gnutls.c:986
static int tls_socket_read(struct Connection *conn, char *buf, size_t count)
Read data from a TLS socket - Implements Connection::read() -.
Definition: gnutls.c:1043
static int tls_socket_write(struct Connection *conn, const char *buf, size_t count)
Write data to a TLS socket - Implements Connection::write() -.
Definition: gnutls.c:1070
int(* poll)(struct Connection *conn, time_t wait_secs)
Definition: connection.h:106
int(* write)(struct Connection *conn, const char *buf, size_t count)
Definition: connection.h:93
int(* close)(struct Connection *conn)
Definition: connection.h:117
int(* read)(struct Connection *conn, char *buf, size_t count)
Definition: connection.h:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getdnsdomainname()

int getdnsdomainname ( struct Buffer result)

Lookup the host's name using DNS.

Parameters
resultBuffer were result of the domain name lookup will be stored
Return values
0Success
-1Error

Definition at line 122 of file getdomain.c.

123{
124 assert(result);
125 int rc = -1;
126
127#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A)
128 char node[256] = { 0 };
129 if (gethostname(node, sizeof(node)) != 0)
130 return rc;
131
132 struct addrinfo *lookup_result = NULL;
133 struct addrinfo hints;
134
135 mutt_buffer_reset(result);
136 memset(&hints, 0, sizeof(struct addrinfo));
137 hints.ai_flags = AI_CANONNAME;
138 hints.ai_family = AF_UNSPEC;
139
140#ifdef HAVE_GETADDRINFO_A
141 lookup_result = mutt_getaddrinfo_a(node, &hints);
142#else
143 lookup_result = mutt_getaddrinfo(node, &hints);
144#endif
145
146 if (lookup_result && lookup_result->ai_canonname)
147 {
148 const char *hostname = strchr(lookup_result->ai_canonname, '.');
149 if (hostname && hostname[1] != '\0')
150 {
151 mutt_buffer_strcpy(result, ++hostname);
152 rc = 0;
153 }
154 }
155
156 if (lookup_result)
157 freeaddrinfo(lookup_result);
158#endif
159
160 return rc;
161}
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:365
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:85
static struct addrinfo * mutt_getaddrinfo(const char *node, const struct addrinfo *hints)
Lookup the host's name using getaddrinfo()
Definition: getdomain.c:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function: