MySQL 8.0.31
Source Code Documentation
node_connection.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef NODE_CONNECTION_H
24#define NODE_CONNECTION_H
25
26#include <stdlib.h>
27
28#ifndef XCOM_WITHOUT_OPENSSL
29#ifdef _WIN32
30/* In OpenSSL before 1.1.0, we need this first. */
31#include <winsock2.h>
32#endif
33
34#include <openssl/ssl.h>
35
36#endif
37
39#include "xcom/xcom_memory.h"
40#include "xcom/xcom_proto.h"
41#include "xdr_gen/xcom_vp.h"
42
44typedef enum con_state con_state;
45
47 int fd;
48#ifndef XCOM_WITHOUT_OPENSSL
49 SSL *ssl_fd;
50#endif
52 unsigned int snd_tag;
53 xcom_proto x_proto;
55};
56
58
59#ifndef XCOM_WITHOUT_OPENSSL
60static inline connection_descriptor *new_connection(int fd, SSL *ssl_fd) {
62 (size_t)1, sizeof(connection_descriptor));
63 c->fd = fd;
64 c->ssl_fd = ssl_fd;
66 return c;
67}
68#else
69static inline connection_descriptor *new_connection(int fd) {
71 (size_t)1, sizeof(connection_descriptor));
72 c->fd = fd;
74 return c;
75}
76#endif
77static inline int is_connected(connection_descriptor *con) {
78 return con->connected_ >= CON_FD;
79}
80
81static inline int proto_done(connection_descriptor *con) {
82 return con->connected_ == CON_PROTO;
83}
84
85static inline void set_connected(connection_descriptor *con, con_state val) {
86 con->connected_ = val;
87}
88
91 con->protocol_stack = val;
92}
93
94#endif /* NODE_CONNECTION_H */
enum_transport_protocol
Enum that describes the available XCom Communication Stacks.
Definition: network_provider.h:42
con_state
Definition: node_connection.h:43
@ CON_NULL
Definition: node_connection.h:43
@ CON_PROTO
Definition: node_connection.h:43
@ CON_FD
Definition: node_connection.h:43
static void set_connected(connection_descriptor *con, con_state val)
Definition: node_connection.h:85
static int proto_done(connection_descriptor *con)
Definition: node_connection.h:81
struct connection_descriptor connection_descriptor
Definition: node_connection.h:57
static int is_connected(connection_descriptor *con)
Definition: node_connection.h:77
static void set_protocol_stack(connection_descriptor *con, enum_transport_protocol val)
Definition: node_connection.h:89
static connection_descriptor * new_connection(int fd, SSL *ssl_fd)
Definition: node_connection.h:60
Definition: node_connection.h:46
xcom_proto x_proto
Definition: node_connection.h:53
enum_transport_protocol protocol_stack
Definition: node_connection.h:54
con_state connected_
Definition: node_connection.h:51
int fd
Definition: node_connection.h:47
SSL * ssl_fd
Definition: node_connection.h:49
unsigned int snd_tag
Definition: node_connection.h:52
static void * xcom_calloc(size_t nmemb, size_t size)
Definition: xcom_memory.h:53