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 | |
| 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 | |
| 38 | struct peer_session { |
| 39 | struct shared_table *table; /* shared table */ |
| 40 | struct peer *peer; /* current peer */ |
| 41 | struct session *session; /* current transport session */ |
| 42 | unsigned int flags; /* peer session flags */ |
| 43 | unsigned int statuscode; /* current/last session status code */ |
| 44 | unsigned int update; /* current peer acked update */ |
| 45 | unsigned int pushack; /* last commited update to ack */ |
| 46 | unsigned int lastack; /* last acked update */ |
| 47 | unsigned int lastpush; /* last pushed update */ |
| 48 | unsigned int confirm; /* confirm message counter */ |
| 49 | unsigned int pushed; /* equal to last pushed data or to table local update in case of total push |
| 50 | * or to teaching_origin if teaching is ended */ |
| 51 | unsigned int reconnect; /* next connect timer */ |
| 52 | unsigned int teaching_origin; /* resync teaching origine update */ |
| 53 | struct peer_session *next; |
| 54 | }; |
| 55 | |
| 56 | struct shared_table { |
| 57 | struct stktable *table; /* stick table to sync */ |
| 58 | struct task *sync_task; /* main sync task */ |
| 59 | struct peer_session *local_session; /* local peer session */ |
| 60 | struct peer_session *sessions; /* peer sessions list */ |
| 61 | unsigned int flags; /* current table resync state */ |
| 62 | unsigned int resync_timeout; /* resync timeout timer */ |
| 63 | struct shared_table *next; /* next shared table in list */ |
| 64 | }; |
| 65 | |
| 66 | struct peer { |
| 67 | int local; /* proxy state */ |
| 68 | char *id; |
| 69 | struct peers *peers; |
| 70 | struct { |
| 71 | const char *file; /* file where the section appears */ |
| 72 | int line; /* line where the section appears */ |
| 73 | } conf; /* config information */ |
| 74 | time_t last_change; |
David du Colombier | 6f5ccb1 | 2011-03-10 22:26:24 +0100 | [diff] [blame] | 75 | struct sockaddr_storage addr; /* peer address */ |
Willy Tarreau | 26d8c59 | 2012-05-07 18:12:14 +0200 | [diff] [blame] | 76 | struct protocol *proto; /* peer address protocol */ |
Willy Tarreau | d02394b | 2012-05-11 18:32:18 +0200 | [diff] [blame^] | 77 | struct sock_ops *sock; /* peer socket operations */ |
| 78 | void *sock_init_arg; /* socket operations's opaque init argument if needed */ |
Emeric Brun | 2b920a1 | 2010-09-23 18:30:22 +0200 | [diff] [blame] | 79 | struct peer *next; /* next peer in the list */ |
| 80 | }; |
| 81 | |
| 82 | |
| 83 | struct peers { |
| 84 | int state; /* proxy state */ |
| 85 | char *id; /* peer section name */ |
| 86 | struct peer *remote; /* remote peers list */ |
| 87 | struct proxy *peers_fe; /* peer frontend */ |
| 88 | struct { |
| 89 | const char *file; /* file where the section appears */ |
| 90 | int line; /* line where the section appears */ |
| 91 | } conf; /* config information */ |
| 92 | struct shared_table *tables; /* registered shared tables */ |
| 93 | time_t last_change; |
| 94 | struct peers *next; /* next peer section */ |
| 95 | int count; /* total of peers */ |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | extern struct peers *peers; |
| 100 | |
| 101 | #endif /* _TYPES_PEERS_H */ |
| 102 | |