Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 30 | #include <common/config.h> |
| 31 | #include <common/mini-clist.h> |
| 32 | #include <common/regex.h> |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 33 | #include <common/tools.h> |
| 34 | #include <eb32tree.h> |
| 35 | |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 36 | struct shared_table { |
| 37 | struct stktable *table; /* stick table to sync */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 38 | int local_id; |
| 39 | int remote_id; |
| 40 | int flags; |
| 41 | uint64_t remote_data; |
| 42 | unsigned int last_acked; |
| 43 | unsigned int last_pushed; |
| 44 | unsigned int last_get; |
| 45 | unsigned int teaching_origin; |
| 46 | unsigned int update; |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 47 | struct shared_table *next; /* next shared table in list */ |
| 48 | }; |
| 49 | |
| 50 | struct peer { |
| 51 | int local; /* proxy state */ |
| 52 | char *id; |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 53 | struct { |
| 54 | const char *file; /* file where the section appears */ |
| 55 | int line; /* line where the section appears */ |
| 56 | } conf; /* config information */ |
| 57 | time_t last_change; |
David du Colombier | 6f5ccb1 | 2011-03-10 22:26:24 +0100 | [diff] [blame] | 58 | struct sockaddr_storage addr; /* peer address */ |
Willy Tarreau | 26d8c59 | 2012-05-07 18:12:14 +0200 | [diff] [blame] | 59 | struct protocol *proto; /* peer address protocol */ |
Willy Tarreau | f7bc57c | 2012-10-03 00:19:48 +0200 | [diff] [blame] | 60 | struct xprt_ops *xprt; /* peer socket operations at transport layer */ |
Willy Tarreau | d02394b | 2012-05-11 18:32:18 +0200 | [diff] [blame] | 61 | void *sock_init_arg; /* socket operations's opaque init argument if needed */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 62 | unsigned int flags; /* peer session flags */ |
| 63 | unsigned int statuscode; /* current/last session status code */ |
| 64 | unsigned int reconnect; /* next connect timer */ |
| 65 | unsigned int confirm; /* confirm message counter */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 66 | struct appctx *appctx; /* the appctx running it */ |
| 67 | struct shared_table *remote_table; |
| 68 | struct shared_table *last_local_table; |
| 69 | struct shared_table *tables; |
Christopher Faulet | 9dcf9b6 | 2017-11-13 10:34:01 +0100 | [diff] [blame] | 70 | __decl_hathreads(HA_SPINLOCK_T lock); /* lock used to handle this peer section */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 71 | struct peer *next; /* next peer in the list */ |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | struct peers { |
| 76 | int state; /* proxy state */ |
| 77 | char *id; /* peer section name */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 78 | struct task *sync_task; /* main sync task */ |
| 79 | struct sig_handler *sighandler; /* signal handler */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 80 | struct peer *remote; /* remote peers list */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 81 | struct peer *local; /* local peer list */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 82 | struct proxy *peers_fe; /* peer frontend */ |
| 83 | struct { |
| 84 | const char *file; /* file where the section appears */ |
| 85 | int line; /* line where the section appears */ |
| 86 | } conf; /* config information */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 87 | time_t last_change; |
| 88 | struct peers *next; /* next peer section */ |
Emeric Brun | b3971ab | 2015-05-12 18:49:09 +0200 | [diff] [blame] | 89 | unsigned int flags; /* current peers section resync state */ |
| 90 | unsigned int resync_timeout; /* resync timeout timer */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 91 | int count; /* total of peers */ |
| 92 | }; |
| 93 | |
| 94 | |
Frédéric Lécaille | ed2b4a6 | 2017-07-13 09:07:09 +0200 | [diff] [blame] | 95 | extern struct peers *cfg_peers; |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 96 | |
| 97 | #endif /* _TYPES_PEERS_H */ |
| 98 | |