|
Packit |
c22fc9 |
/*
|
|
Packit |
c22fc9 |
* Soft: Keepalived is a failover program for the LVS project
|
|
Packit |
c22fc9 |
* <www.linuxvirtualserver.org>. It monitor & manipulate
|
|
Packit |
c22fc9 |
* a loadbalanced server pool using multi-layer checks.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Part: layer4.c include file.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Author: Alexandre Cassen, <acassen@linux-vs.org>
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
c22fc9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
c22fc9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
c22fc9 |
* See the GNU General Public License for more details.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* This program is free software; you can redistribute it and/or
|
|
Packit |
c22fc9 |
* modify it under the terms of the GNU General Public License
|
|
Packit |
c22fc9 |
* as published by the Free Software Foundation; either version
|
|
Packit |
c22fc9 |
* 2 of the License, or (at your option) any later version.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
|
|
Packit |
c22fc9 |
*/
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifndef _LAYER4_H
|
|
Packit |
c22fc9 |
#define _LAYER4_H
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* system includes */
|
|
Packit |
c22fc9 |
#include <sys/socket.h>
|
|
Packit |
c22fc9 |
#include <net/if.h>
|
|
Packit |
c22fc9 |
#include <stdbool.h>
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* local includes */
|
|
Packit |
c22fc9 |
#include "scheduler.h"
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
enum connect_result {
|
|
Packit |
c22fc9 |
connect_error,
|
|
Packit |
c22fc9 |
connect_in_progress,
|
|
Packit |
c22fc9 |
connect_timeout,
|
|
Packit |
c22fc9 |
connect_success
|
|
Packit |
c22fc9 |
};
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* connection options structure definition */
|
|
Packit |
c22fc9 |
typedef struct _conn_opts {
|
|
Packit |
c22fc9 |
struct sockaddr_storage dst;
|
|
Packit |
c22fc9 |
struct sockaddr_storage bindto;
|
|
Packit |
c22fc9 |
char bind_if[IFNAMSIZ];
|
|
Packit |
c22fc9 |
unsigned int connection_to; /* connection time-out */
|
|
Packit |
c22fc9 |
#ifdef _WITH_SO_MARK_
|
|
Packit |
c22fc9 |
unsigned int fwmark; /* to mark packets going out of the socket using SO_MARK */
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
} conn_opts_t;
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* Prototypes defs */
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
extern enum connect_result
|
|
Packit |
c22fc9 |
socket_bind_connect(int, conn_opts_t *);
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
extern enum connect_result
|
|
Packit |
c22fc9 |
socket_connect(int, struct sockaddr_storage *);
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
extern enum connect_result
|
|
Packit |
c22fc9 |
socket_state(thread_t *, int (*func) (thread_t *));
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
extern bool
|
|
Packit |
c22fc9 |
socket_connection_state(int, enum connect_result
|
|
Packit |
c22fc9 |
, thread_t *, int (*func) (thread_t *)
|
|
Packit |
c22fc9 |
, unsigned long);
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* Backward compatibility */
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
static inline enum connect_result
|
|
Packit |
c22fc9 |
tcp_bind_connect(int fd, conn_opts_t *co)
|
|
Packit |
c22fc9 |
{
|
|
Packit |
c22fc9 |
return socket_bind_connect(fd, co);
|
|
Packit |
c22fc9 |
}
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
static inline enum connect_result
|
|
Packit |
c22fc9 |
tcp_connect(int fd, struct sockaddr_storage *addr)
|
|
Packit |
c22fc9 |
{
|
|
Packit |
c22fc9 |
return socket_connect(fd, addr);
|
|
Packit |
c22fc9 |
}
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
static inline enum connect_result
|
|
Packit |
c22fc9 |
tcp_socket_state(thread_t * thread, int (*func) (thread_t *))
|
|
Packit |
c22fc9 |
{
|
|
Packit |
c22fc9 |
return socket_state(thread, func);
|
|
Packit |
c22fc9 |
}
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
static inline bool
|
|
Packit |
c22fc9 |
tcp_connection_state(int fd, enum connect_result status, thread_t * thread,
|
|
Packit |
c22fc9 |
int (*func) (thread_t *), unsigned long timeout)
|
|
Packit |
c22fc9 |
{
|
|
Packit |
c22fc9 |
return socket_connection_state(fd, status, thread, func, timeout);
|
|
Packit |
c22fc9 |
}
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#endif
|