Merge branch '2.1-ipv6' into develop

This commit is contained in:
Markus Mäkelä
2017-03-13 13:18:08 +02:00
17 changed files with 412 additions and 423 deletions

View File

@ -195,7 +195,7 @@ typedef struct dcb
int flags; /**< DCB flags */
char *remote; /**< Address of remote end */
char *user; /**< User name for connection */
struct sockaddr_in ipv4; /**< remote end IPv4 address */
struct sockaddr_storage ip; /**< remote IPv4/IPv6 address */
char *protoname; /**< Name of the protocol */
void *protocol; /**< The protocol specific state */
size_t protocol_packet_length; /**< How long the protocol specific packet is */
@ -236,7 +236,7 @@ typedef struct dcb
} DCB;
#define DCB_INIT {.dcb_chk_top = CHK_NUM_DCB, \
.evq = DCBEVENTQ_INIT, .ipv4 = {0}, .func = {0}, .authfunc = {0}, \
.evq = DCBEVENTQ_INIT, .ip = {0}, .func = {0}, .authfunc = {0}, \
.stats = {0}, .memdata = DCBMM_INIT, \
.fd = DCBFD_CLOSED, .stats = DCBSTATS_INIT, .ssl_state = SSL_HANDSHAKE_UNKNOWN, \
.state = DCB_STATE_ALLOC, .dcb_chk_tail = CHK_NUM_DCB, \
@ -339,6 +339,14 @@ void dcb_process_idle_sessions(int thr);
*/
bool dcb_foreach(bool (*func)(DCB *, void *), void *data);
/**
* @brief Return the port number this DCB is connected to
*
* @param dcb DCB to inspect
* @return Port number the DCB is connected to or -1 if information is not available
*/
int dcb_get_port(const DCB *dcb);
/**
* DCB flags values
*/

View File

@ -35,13 +35,41 @@ MXS_BEGIN_DECLS
*/
#define MXS_PTR(a, b) (((uint8_t*)(a)) + (b))
/** The type of the socket */
enum mxs_socket_type
{
MXS_SOCKET_LISTENER, /**< */
MXS_SOCKET_NETWORK,
};
bool utils_init(); /*< Call this first before using any other function */
void utils_end();
int setnonblocking(int fd);
int parse_bindconfig(const char *, struct sockaddr_in *);
int setipaddress(struct in_addr *, char *);
/**
* @brief Create a network socket and a socket configuration
*
* This helper function can be used to open both listener socket and network
* connection sockets. For listener sockets, the @c host and @c port parameters
* tell where the socket will bind to. For network sockets, the parameters tell
* where the connection is created.
*
* After calling this function, the only thing that needs to be done is to
* give @c addr and the return value of this function as the parameters to
* either bind() (for listeners) or connect() (for outbound network connections).
*
* @param type Type of the socket, either MXS_SOCKET_LISTENER for a listener
* socket or MXS_SOCKET_NETWORK for a network connection socket
* @param addr Pointer to a struct sockaddr_storage where the socket
* configuration is stored
* @param host The target host for which the socket is created
* @param port The target port on the host
*
* @return The opened socket or -1 on failure
*/
int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr,
const char *host, uint16_t port);
int setnonblocking(int fd);
char *gw_strend(register const char *s);
static char gw_randomchar();
int gw_generate_random_str(char *output, int len);