blob: 320e128c857a76dd2905a7fb44141944769ec50e [file] [log] [blame]
Emeric Brun2b920a12010-09-23 18:30:22 +02001/*
2 * include/types/peers.h
3 * This file defines everything related to peers.
4 *
5 * Copyright 2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _TYPES_PEERS_H
23#define _TYPES_PEERS_H
24
25#include <sys/types.h>
26#include <sys/socket.h>
27#include <netinet/in.h>
28#include <arpa/inet.h>
29
30#include <common/appsession.h>
31#include <common/config.h>
32#include <common/mini-clist.h>
33#include <common/regex.h>
34#include <common/sessionhash.h>
35#include <common/tools.h>
36#include <eb32tree.h>
37
Emeric Brun2b920a12010-09-23 18:30:22 +020038struct shared_table {
39 struct stktable *table; /* stick table to sync */
Emeric Brunb3971ab2015-05-12 18:49:09 +020040 int local_id;
41 int remote_id;
42 int flags;
43 uint64_t remote_data;
44 unsigned int last_acked;
45 unsigned int last_pushed;
46 unsigned int last_get;
47 unsigned int teaching_origin;
48 unsigned int update;
Emeric Brun2b920a12010-09-23 18:30:22 +020049 struct shared_table *next; /* next shared table in list */
50};
51
52struct peer {
53 int local; /* proxy state */
54 char *id;
Emeric Brun2b920a12010-09-23 18:30:22 +020055 struct {
56 const char *file; /* file where the section appears */
57 int line; /* line where the section appears */
58 } conf; /* config information */
59 time_t last_change;
David du Colombier6f5ccb12011-03-10 22:26:24 +010060 struct sockaddr_storage addr; /* peer address */
Willy Tarreau26d8c592012-05-07 18:12:14 +020061 struct protocol *proto; /* peer address protocol */
Willy Tarreauf7bc57c2012-10-03 00:19:48 +020062 struct xprt_ops *xprt; /* peer socket operations at transport layer */
Willy Tarreaud02394b2012-05-11 18:32:18 +020063 void *sock_init_arg; /* socket operations's opaque init argument if needed */
Emeric Brunb3971ab2015-05-12 18:49:09 +020064 unsigned int flags; /* peer session flags */
65 unsigned int statuscode; /* current/last session status code */
66 unsigned int reconnect; /* next connect timer */
67 unsigned int confirm; /* confirm message counter */
68 struct stream *stream; /* current transport stream */
69 struct appctx *appctx; /* the appctx running it */
70 struct shared_table *remote_table;
71 struct shared_table *last_local_table;
72 struct shared_table *tables;
Emeric Brun2b920a12010-09-23 18:30:22 +020073 struct peer *next; /* next peer in the list */
74};
75
76
77struct peers {
78 int state; /* proxy state */
79 char *id; /* peer section name */
Emeric Brunb3971ab2015-05-12 18:49:09 +020080 struct task *sync_task; /* main sync task */
81 struct sig_handler *sighandler; /* signal handler */
Emeric Brun2b920a12010-09-23 18:30:22 +020082 struct peer *remote; /* remote peers list */
Emeric Brunb3971ab2015-05-12 18:49:09 +020083 struct peer *local; /* local peer list */
Emeric Brun2b920a12010-09-23 18:30:22 +020084 struct proxy *peers_fe; /* peer frontend */
85 struct {
86 const char *file; /* file where the section appears */
87 int line; /* line where the section appears */
88 } conf; /* config information */
Emeric Brun2b920a12010-09-23 18:30:22 +020089 time_t last_change;
90 struct peers *next; /* next peer section */
Emeric Brunb3971ab2015-05-12 18:49:09 +020091 unsigned int flags; /* current peers section resync state */
92 unsigned int resync_timeout; /* resync timeout timer */
Emeric Brun2b920a12010-09-23 18:30:22 +020093 int count; /* total of peers */
94};
95
96
97extern struct peers *peers;
98
99#endif /* _TYPES_PEERS_H */
100