NeoMutt  2024-04-25-102-g19653a
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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.
 
int getdnsdomainname (struct Buffer *result)
 Lookup the host's name using DNS.
 

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 1145 of file gnutls.c.

1146{
1147 if (tls_init() < 0)
1148 return -1;
1149
1150 if (tls_negotiate(conn) < 0)
1151 return -1;
1152
1153 conn->read = tls_socket_read;
1154 conn->write = tls_socket_write;
1155 conn->close = tls_starttls_close;
1156 conn->poll = tls_socket_poll;
1157
1158 return 0;
1159}
static int tls_init(void)
Set up Gnu TLS.
Definition: gnutls.c:92
static int tls_negotiate(struct Connection *conn)
Negotiate TLS connection.
Definition: gnutls.c:872
static int tls_starttls_close(struct Connection *conn)
Close a TLS connection - Implements Connection::close() -.
Definition: gnutls.c:1106
static int tls_socket_poll(struct Connection *conn, time_t wait_secs)
Check if any data is waiting on a socket - Implements Connection::poll() -.
Definition: gnutls.c:988
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:1045
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:1072
int(* poll)(struct Connection *conn, time_t wait_secs)
Definition: connection.h:105
int(* write)(struct Connection *conn, const char *buf, size_t count)
Definition: connection.h:92
int(* close)(struct Connection *conn)
Definition: connection.h:116
int(* read)(struct Connection *conn, char *buf, size_t count)
Definition: connection.h:79
+ 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 124 of file getdomain.c.

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